SQL Copy Table

To copy the contents of one table to another table is done by using SELECT statement

The two tables that we use should be present in the same database.

The syntax for copying table is

SELECT * INTO destination_table FROM source_table;

 

Example:

Let us take two tables Student and Employees.

Table 1: Student

StudentID Student_Name Address City
1 Nithin Bank Street Hyderabad
2 Bharath Panama Street California

 

Table 2: Employees

StudentID Student_Name Address City


Now we copy the contents of Student table to Employees table by using SELECT statement as follows:

SELECT * INTO Employees FROM Student;

 

Now the Table Employees will look like this:

StudentID Student_Name Address City
1 Nithin Bank Street Hyderabad
2 Bharath Panama Street California