Cloning Table in MySQL

There may be a number of occasions where you need to create an exact copy of an already defined (or created) table. MySQL enables you to perform this operation. Because we may need such duplicate tables for testing over the data without having any impact over the original table and the data stored in it.

Original_table –

ID F_name L_name Project_id Email Job_Title City Age Salary
1. Madhav Mohan Sharma A-1 W_@.com SDE Agra 21 70,000/-
2. Mukund Mohan Sharma B-2 V_@.com SDE Delhi 21 70,000/-
3. Jay Sharma C-3 X_@.com Sr.SDE Banglore 29 1,50,000/-
4. Parag Sharma D-4 y_@.com SDE Mumbai 27 80,000/-
5. Anshika Goyal E-5 Z_@.com Hr Mgr Noida 26 90,000/-




Steps to replicate (Clone) an existing table schema (structure) and it’s content –

Step 1 : To clone a table, use the query below. Using this query an empty schema (structure) of the table gets created with the same attributes of original table :

CREATE TABLE Contact List(Clone_1) LIKE Original_table;

Output : Contact List (Clone_1)

ID F_name L_name projrct_id Email Job_Title City Age Salary



Step 2 : If you want to create a table which is bedecked with all the content of your original table, use this MySQL query :

CREATE TABLE Contact List(Clone_1) AS SELECT * 
FROM Original_table; 
                 OR
INSERT INTO Contact List(Clone_1) SELECT * 
FROM original_table;

Output : Contact List (Clone_1)

ID F_name L_name Project_id Email Job_Title City Age Salary
1. Madhav Mohan Sharma A-1 W_@.com SDE Agra 21 70,000/-
2. Mukund Mohan Sharma B-2 V_@.com SDE Delhi 21 70,000/-
3. Jay Sharma C-3 X_@.com Sr.SDE Banglore 29 1,50,000/-
4. Parag Sharma D-4 y_@.com SDE Mumbai 27 80,000/-
5. Anshika Goyal E-5 Z_@.com Hr Mgr Noida 26 90,000/-

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.