Skip links

How to create a copy of a table in SQL

How to create a copy of a table in SQL

To create a copy of a table in SQL, you can use either of the following methods:

a). Using the CREATE TABLE statement with a SELECT statement:

CREATE TABLE new_table AS
SELECT * FROM original_table;

This method creates a new table with the same structure and data as the original.

The new table will have the same columns, data types, and constraints as the original table and will contain all of the data from the original table.

b). Using the INSERT INTO statement:

INSERT INTO new_table
SELECT * FROM original_table;

This method creates a new table and inserts all of the data from the original table into it.

Before using this method, you must create a new table with the same structure as the original.

Whichever you pick, you need to replace “original_table” with the name of the original table and “new_table” with the name you want to give to the new table.