Hello.

On Mon 2002-06-24 at 17:06:19 -0400, [EMAIL PROTECTED] wrote:
> I want to copy the structure of a table to a brand new table, but I
> don't want to use phpmyadmin or some other program.  I'm looking for the
> command line code.
>  
> Anyone have a link to where I can find it?  Or, anyone wanna send me
> the code?

I think there is no automatic, MySQL-only way to do that. You can use

  CREATE TABLE newtable SELECT * FROM oldtable ...

but this will lose indexes and maybe get other things different (like
varchar vs. char).


The method I use with UNIX shell is 

  mysqldump -d mydb oldtable | sed -e 's/oldtable/newtable/' | mysql mydb

Of course, "oldtable" should be unique, else the sed regexp should
contain some safety delimiters.

HTH,

        Benjamin.

-- 
[EMAIL PROTECTED]

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to