Previous | Home | Next |
A SELECT statement with the INTO clause is used to store the result set in a new table without a data definition process. The SELECT INTO statement creates a new table.
If the table is already exists, then the operation fails.
The command syntax is the,
SELECT columns_list INTO new_table_name FROM table_name 1, table_name 2.. table_name n WHERE condition 1, condition 2..condition n
Where coloumn_list is the list of columns to be included in the new table.
new_table_name is the name of the new table where data is to be stored.
condition is the conditions on which rows are to be included in the new table..
Example:
Create a new table from the title table.
SELECT title_id ,title INTO aditya FROM titles WHERE price>15
(8 row(s) affected)
SELECT * FROM aditya
output
A new table created named aditya
Previous | Home | Next |