SQL SELECT INTO Statement
The SQL SELECT INTO statement is used in SQL to copy data from one table and insert it into a new table.
It’s commonly used for creating backup and temporary tables or extracting a subset of data from one table and storing it in another.
SYNTAX:
SELECT column1, column2, …
INTO new_table
FROM source_table
WHERE condition;
Let’s understand the select into statement with an example. For demonstration purposes, we will be using the table emp
Table EMP
Example:
Objective: In this example, we will create a new table using the old table’s column names and data types.
SELECT * INTO Tbl_Emp_Copy FROM Tbl_Emp
Query:
SELECT * FROM Tbl_Emp_Copy;
Output: