1. Select into :
Suppose a table has some particular rows that has to be transferred to another table of the same database. It can be done using select into statement as follows –
select list into destination from source (where condition)
There are two tables named student and marks. The marks of the students has to be transferred from marks to student table. This has to be done as :
Select * from student;
Select * from marks;
Select mks into student from marks;
The marks will be added into the student table. The ‘where’ clause can be used for condition. It is optional.
2. Temporary tables :
The user at times wants to create a separate table from the given table values. It has to be done using the temporary tables concept. Temporary tables can be created in two ways: using create table syntax or select into syntax.
Select into :
A new table has to created from the student table using select into statement as follows :
Select * from student;
Select name, rollno into temp_table #details from student;
Create table :
A new table can be created using create table statement :
Create table #details( name varchar2(30), rollno int);
A new table is created. The values can be copied from the other table as follows :
Insert into #details select name, rollno from student;
- SQL | SELECT data from Multiple Tables
- Copy tables between databases in SQL Server using Import-and-Export Wizard
- Insert Into Select statement in MS SQL Server
- Copy tables between databases in SQL Server
- Select statement in MS SQL Server
- Select top in MS SQL Server
- What is Temporary Table in SQL?
- SQL | Declare Local Temporary Table
- SELECT INTO statement in SQL
- Joining three or more tables in SQL
- Difference between Structured Query Language (SQL) and Transact-SQL (T-SQL)
- Performing Database Operations in Java | SQL CREATE, INSERT, UPDATE, DELETE and SELECT
- SQL | SELECT Query
- SQL | SELECT TOP Clause
- SQL | Query to select NAME from table using different options
- Mean and Mode in SQL Server
- Difference between MySQL and MS SQL Server
- Difference between Couchbase and MS SQL Server
- Create, Alter and Drop schema in MS SQL Server
- Difference between MS SQL Server and CouchDB
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.