Ok, although 20,000 rows aren't really that much. Should only take a second to clone such a table using the syntax I suggested. (Unless it has an extraordinary amount of columns, of course.)
I tested it on my local server. Took a table with a PK, two text columns and a date column only, and with 21.005 rows, about 0.5 - 0.8 seconds to execute each statement. (Where both text columns were indexed.)
But anyhow...
@jeddiki
It's all explained in
the manual.
In this case, it would go something like this:
- CREATE TABLE `table_name`
-
(create table definitions...)
-
[table options]
-
[select statement]
And note that if the select statement returns a column that is not defined in the create table definitions, it will simply be added. Which means you can define any special columns (auto_increment, primary key, indexes, etc...) in the
create table definitions, but leave out those that need no special attention and have them created automatically.
Here you will also have to define the table options, such as the storage engine, the charset and the auto_increment position. (The LIKE clause in my previous suggestion takes care of that automatically, but this syntax does not.)
Your query is missing the parenthesis around the
create table definitions (the KEY statements). Otherwise, besides the table options, it should work.