SQL tutorial

SQL Select Into

Learn more about SQL, a standard language for interacting with databases and storing, manipulating, and retrieving data from databases.

Go hands-on with SQL in our free interactive SQL tutorial.

The SQL SELECT INTO is an alternative syntax which can be used to perform the same actions as an INSERT INTO statement combined with a SELECT statement. Not all SQL dialects support this syntax.

This combination statement takes the general form:

Code Example
SELECT <columns> INTO <destination table> FROM <source table>;

As this is using a SELECT statement, all the usual SQL constructs (expressions, WHERE clauses, etc.) can be applied to filter and manipulate the data as desired and write out the result into the destination table.

In the previous section, we saw we could dump all the records from the employees table into a new table using the INSERT INTO SELECT syntax as below:

Code Example
INSERT INTO employees_backup SELECT * FROM employees;

To use the SQL SELECT INTO syntax instead, this would take the form as below:

Code Example
SELECT * INTO employees_backup FROM employees;

As with other data manipulation statements, no records are returned as a result of the query, only confirmation of execution success or failure and the number of records affected.

Learn SQL Today

Get hands-on experience writing code with interactive tutorials in our free online learning platform.

  • Free and fun
  • Designed for beginners
  • No downloads or setup required