Re: MySQL rename and indexes

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Alex Dean
Date:  
To: discussion list Main
Subject: Re: MySQL rename and indexes

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
.



---------------------------------------------------
PLUG-discuss mailing list -
To subscribe, unsubscribe, or to change you mail settings:
http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss