SQL COPY TABLE

The SQL COPY TABLE statement is used to copy data from one table to another table within the same database server.

If you want to copy a SQL table to another table in the MySQL database, it is possible by using select INTO command.

SQL COPY TABLE Syntax

The basic syntax for copying one table to another is as follows.

SELECT * INTO <destination_table> from <source_table>;

HERE,

<destination_table> – Where you want to copy the data.
<source_table> – The source table from where you want to copy.

SQL COPY TABLE Example

Suppose, you have an employee table as below.

EmpNo Name  Salary
121 Sagar 85000
122 Shankar 70000
123 Ravi 60000
124 Nick 95000

If you want to copy this employee table to a new table named employee_salary, then you can follow the below command.

SELECT * INTO employee_salary from employee;

Note: SELECT INTO and INSERT INTO are totally different statements.

Leave a Comment