Skip to content
Related Articles

Related Articles

Cloning Table in MySQL

Improve Article
Save Article
  • Last Updated : 26 Jul, 2020
Improve Article
Save Article

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 –

IDF_nameL_nameProject_idEmailJob_TitleCityAgeSalary
1.MadhavMohan SharmaA-1W_@.comSDEAgra2170,000/-
2.MukundMohan SharmaB-2V_@.comSDEDelhi2170,000/-
3.JaySharmaC-3X_@.comSr.SDEBanglore291,50,000/-
4.ParagSharmaD-4y_@.comSDEMumbai2780,000/-
5.AnshikaGoyalE-5Z_@.comHr MgrNoida2690,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)

IDF_nameL_nameprojrct_idEmailJob_TitleCityAgeSalary



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)

IDF_nameL_nameProject_idEmailJob_TitleCityAgeSalary
1.MadhavMohan SharmaA-1W_@.comSDEAgra2170,000/-
2.MukundMohan SharmaB-2V_@.comSDEDelhi2170,000/-
3.JaySharmaC-3X_@.comSr.SDEBanglore291,50,000/-
4.ParagSharmaD-4y_@.comSDEMumbai2780,000/-
5.AnshikaGoyalE-5Z_@.comHr MgrNoida2690,000/-

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!