SELECT INTO statement can be used to create backup copy of a table.This sql statement selects records from one table according to the selection we make and inserts the result set into another new table with the table name we specify.
Syntax given below is used to make a exact copy of the table.That is it creates the table with the same no of columns and all records in the old table.
SELECT *
INTO new_table_name
FROM old_table_name
select * into employee_backup from employee
In this example a exact copy of the table employee is backed up as a new table employee_backup.
Syntax given below is used to make a new table with selected columns from old table.
SELECT column_name(s)
INTO new_table_name
FROM old_table_name
select employee_id,employee_name into employee_backup from employee
In this example a copy of the table employee with only columns “employee_id,employee_name” is backed up as a new table employee_backup.
Popularity: 9% [?]

December 29th, 2008
admin
Posted in
Tags:

