SQL COPY Table - Javatpoint
SQL COPY Table - Javatpoint
The SELECT INTO statement in Structured Query Language copies the content from one existing table
into the new table. SQL creates the new table by using the structure of the existing table.
Example 1: In this example, we have a table called Cars with three columns:
Table: Cars
Suppose you want to copy the content of the above Car table into the new table Car_Details. For
this, you have to type the following query in SQL:
Let's check the Car_Details table is created successfully or not in the database:
Table: Car_Details
Example 2: In this example, we have a table called Employee with four columns:
Suppose you want to copy the record of the above Employee table into the new table
Coding_Employees. For this, you have to type the following query in SQL:
Let's check the Coding_Employees table is created successfully or not in the database:
Table: Coding_Employees
Example 3: In this example, we have a table called Student with four columns:
RollNo Name Marks Age
1001 Bhanu 88 17
1002 Raman 82 16
1003 Sumit 80 16
1004 Shobhit 95 15
1005 Akash 85 16
Table: Student
Suppose you want to copy the record of the above Student table into the new table
Class_12_Students. For this, you have to type the following query in SQL:
Let's check the table is Class_12_Students table created successfully or not in the database:
1001 Bhanu 88 17
1002 Raman 82 16
1003 Sumit 80 16
1004 Shobhit 95 15
1005 Akash 85 16
Table: Class_12_Students
Example 4: In this example, we have a table called Cars with three columns:
Table: Cars
Suppose you want to copy Car_Color and Car_Name columns of the above Cars table into the
new table Car_Color. For this, you have to type the following query in SQL:
Let's check the Car_Color table is created successfully or not in the database:
Table: Car_Color
Here, we have taken the following three different SQL examples, which will help you how to copy the
content of one table into another table with a specific condition in SQL:
Example 1: In this example, we have a table called Cars with three columns:
Table: Cars
Suppose we want to copy only the record of those cars whose color is black. For this, we have to
type the following query in SQL:
Let's check the Black_Car_Details table is created successfully or not in the database:
Table: Black_Car_Details
Example 2: In this example, we have a table called Employee with four columns:
Table: Employee
Suppose we want to copy only the record of those employees whose Salary is more than 40,000.
For this, we have to type the following query in SQL:
Let's check the Emp_Salary_40000 table created successfully or not in the database:
Table: Emp_Salary_40000
← Prev Next →
Preparation
Trending Technologies
B.Tech / MCA