SQL COPY TABLE: How to Copy Data from One Table to Another
When working with databases, you may need to duplicate data from one table into another for analysis, backups, or temporary operations. This is commonly done using the SELECT INTO statement, which copies both the structure and data of an existing table into a new table.
Complete Python Course with Advance topics:-
SQL Tutorial:-
Syntax of SELECT INTO
SELECT * INTO New_Table FROM Old_Table;
Important: MySQL Uses CREATE TABLE AS SELECT
Note that SELECT INTO works in SQL Server and MS Access. In MySQL and PostgreSQL, use CREATE TABLE AS SELECT instead:
CREATE TABLE New_Table AS
SELECT * FROM Old_Table;
Example 1: Copying All Data
SELECT * INTO Vehicle_Details FROM Vehicles;
Example 2: Copying Specific Columns
SELECT Gadget_Name, Price
INTO Gadget_Pricing
FROM Gadgets;
Example 3: Copying Specific Rows with WHERE
SELECT * INTO Self_Help_Books
FROM Books
WHERE Genre = 'Self-help';
Example 4: Copying with a Numeric Filter
SELECT * INTO High_End_Laptops
FROM Laptops
WHERE Price > 75000;
Copy Structure Only (No Data)
To copy only the structure without rows, add a false condition:
SELECT * INTO New_Table FROM Old_Table WHERE 1 = 0;
Download New Real Time Projects:- Click here
Complete Advance AI topics:-
Conclusion
Copying tables is simple with SELECT INTO (SQL Server) or CREATE TABLE AS SELECT (MySQL/PostgreSQL). Whether copying all records, selected columns, or filtered rows, these methods make data duplication efficient. For more SQL tips, visit .
sql copy table to another table
how to create duplicate table in sql with data
mysql copy table
sql select into existing table
copy table structure without data
create table as select
sql copy table example
postgresql copy table