|
Posted by Tom on 11/26/07 19:07
On Sat, 24 Nov 2007 10:21:06 +0100, Flemming wrote...
>
>>>Is there a smarter way?
>>>
>>>Flemming
>>>
>>
>>
>> I'd run a separate command to create your new table, then use
>>
>> SELECT * INTO NewTable FROM OldTable;
>>
>> Of course I'd do a regular backup of your entire database first, just for
>> precautionary measures.
>>
>Thank you your reply.
>
>Is there a way to create (an empty) NewTable in SQL with indexes and all
>from OldTable?
>
>Flemming
>
I usually create my own "config" files, that I use similar to restoring from a
backup. As an example, I'll create a file named OldTable.sql that includes the
SQL commands for creating the table and adding its indexes, and using a command
like this to create the table...
mysql -u username -p database_name < /path/to/OldTable.sql
If I need to create a similar or duplicate table, I can copy that to a
NewTable.sql file, and edit that with whatever changes I needed. Then add that
one using..
mysql -u username -p database_name < /path/to/NewTable.sql
That way you can duplicate a table design a lot easier.
Tom
--
NewsGuy Accounts Go Jumbo!
Extra NewsGuy increased from 30 to 50 GB of download capacity
http://newsguy.com/overview.htm
[Back to original message]
|