How to create duplicate table in sql with data
- copy of table in sql
- copy of table in sql server
- backup of table in sql
- backup of table in sql server
How to create duplicate table in sql without data
How to copy data from one table to another table in different database in sql!
SQL Cloning Tables
In this tutorial you will learn how to create a duplicate copy of an existing table.
Cloning or Copying a Table
There may be a situation when you just want to create an exact copy or clone of an existing table to test or perform something without affecting the original table.
The following section describes how to do this in few easy steps.
Step 1: Creating an Empty Table
First use the following statement to create an empty table based on the definition of original table.
It also includes the column attributes and indexes defined in the original table:
CREATE TABLEnew_tableLIKEoriginal_table;
Step 2: Inserting Data into Table
Now, use the following statement to populate the empty table with data from original table:
INSERT INTOnew_tableSELECT * FROMoriginal_table;
Let's make a clone of the table using the MySQL command-line tool.
Consider we've an employees table in our database that has the following records:
+--------+--------------+------------+--------+---------+ | emp_id | emp_name | hire_date | salary | dept_id | +--------+------- clone of table in sql
- create copy of table in sql