At 13:22 -0600 2/8/02, BD wrote: >At 10:34 AM 2/8/2002 , you wrote: > >Quite often I'd like to duplicate an existing table using SQL. >Normally I'd do a > >create table NewTable select * from OldTable; > >and if I don't want any data transferred I'll slap on a Limit 0 on the end >of the statement. > >This works fine except it doesn't create any indexes that OldTable had. Is >there a generic way to duplicate a table that includes the indexes? >I don't want to have to manually create indexes for it.
Not using just SQL, no. In a program, you can get the output from a SHOW CREATE TABLE statement, perform a substitution to change the table name, then execute the statement. That will create a copy (empty) that includes the indexes. > >TIA > >Brent --------------------------------------------------------------------- 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