SQL SELECT INTO Statement

The SQL SELECT INTO statement is used to create a duplicate table of another table.

The SQL SELECT INTO statement selects or copies data with column structure from one table and inserts it into a new database table.


Search Keys

  • sql select into statement
  • mssql select into
  • sql select into temp table
  • select into temp table
  • postgresql select into
  • sql server select into existing table
  • select into example
  • select into new table
  • sql server select into temp table
  • sql select into new table
  • create table select into
  • select into temp table sql server
  • insert select into table
  • sql select into from
  • select into existing table
  • select into temp

SQL SELECT INTO Statement Syntax

The below syntax is used to select all column(s) and records from a table to another new table.


SELECT *
INTO newtablename
FROM table1
[WHERE Condition];

The below syntax is used to select specific column(s) and all records from a table to another new table.


SELECT column_name1, column_name2, ...column_nameN
INTO newtablename
FROM table1
[WHERE Condition];

The new table will be created with the column names and datatypes as defined in the SQL SELECT statement. You can apply new names using the SQL Alias clause.


Sample Database Table - Books

BookId BookName BookPrice RelYear DomainName AuthorName
1 Oracle Concurrency 80 2006 Programming Bala Murugan
2 Professional Oracle 135 2013 Programming Dharan
3 Simply MySql 100 2010 Database Vidyavathi
4 Easy Oracle PL/SQL Programming 185 2006 Security Ramanathan
5 Troubleshooting Oracle 84.22 2009 Performance Harish Karthik
6 SQL in a Nutshell 110 2008 Optimization Balan
7 Microsoft SQL Server 2008 170 2014 Optimization Pandurengan
8 MySql Database Internals 168.27 2015 Programming Bala Murugan
9 SQL Server Database Internals 150 2014 Database Azaghu Varshith
10 MySql Concurrency 199.97 2009 Security Geetha
11 Jump Start MySQL 165 2006 Administration Siva Kumar
12 SQL Visual Quickstart 136.33 2014 Programming Ranjani Mai

SQL SELECT INTO Query Example

The following SQL SELECT statement will create a backup copy of "Books" table:


SELECT *
INTO BooksBackup2015
FROM Books;

The following SQL SELECT statement will Copy only a few columns into the new table:


SELECT BookName, AuthorName, BookPrice
INTO BooksBackup2012
FROM Books;

The following SQL SELECT statement will Copy only the "Database" domain records into the new table:


SELECT *
INTO BooksDomainBackup
FROM Books
WHERE Domain = 'Database';


Search Keys

  • copy sql database
  • sql copy data from one table to another
  • copy data from one table to another in sql
  • copy data from one table to another sql
  • copy sql
  • sql copy
  • copy from table to table sql
  • sql copy from table to table
  • sql copy data between tables
  • create copy of table sql
  • create table as select
  • create table from select
  • sql create table from select
  • insert create table
  • create table with insert
  • create table select sql