MySQL rename and indexes
Alex Dean
alex at crackpot.org
Fri Nov 3 20:03:40 MST 2006
On Nov 3, 2006, at 7:58 PM, Alex Dean wrote:
>
> On Nov 3, 2006, at 6:35 PM, der.hans wrote:
>
>>> Any tips on creating a new table and indexes based on another
>>> table and
>>> its indexes?
>
> To create a new table based on an existing one, you can to this :
> "CREATE TABLE new_table LIKE old_table"
>
> This is just the column and index information. If you also want
> the data, next do : "INSERT INTO new_table SELECT * FROM old_table"
One caveat about that approach : The 'CREATE ... LIKE ...' will copy
indexes, but it won't automatically copy any foreign keys you've
defined. You'd need to re-add them yourself.
http://dev.mysql.com/doc/refman/5.0/en/create-table.html
alex
.
More information about the PLUG-discuss
mailing list