List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:February 8 2002 7:27pm
Subject:Re: How to duplicate a table complete with indexes? #
View as plain text  
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

Thread
How to duplicate a table complete with indexes? #BD8 Feb
  • Re: How to duplicate a table complete with indexes? #Paul DuBois8 Feb
  • update to mysql 4.01 under mandrakeDavid yahoo8 Feb