Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mysql query to copy the structure of a table to create another table

Tags:

Looking for help in creating a Mysql query to copy the structure of an existing table to create another table.

like image 571
Hari kanna Avatar asked Jun 09 '10 10:06

Hari kanna


People also ask

How do you copy the structure of a existing table student to new table new student?

To export data to an existing table you can use insert command. This will create a new table student2 using the structure of the table student and will copy all the records from table student to our new table student2. This became more useful when we add conditions to this by using SQL WHERE command.

What command is used to create a table by copying the structure of another table in MySQL?

What command is used to create a table by copying the structure of another table? CREATE TABLE As SELECT Command. Explanation: To copy only the structure the where clause of the SELECT command should have a FALSE statement.


1 Answers

To create a table as in an exact replica of another table:

CREATE TABLE `new_table_name` LIKE `old_table_name`; 
like image 157
Hammerite Avatar answered Nov 02 '22 23:11

Hammerite