SQL Tutorial: SQL SELECT into instance tutorial
A table in which the SQL SELECT into statement can be used to make a backup copy.
In SQL SELECT into statement
Select the data from a table in the SELECT INTO statement and insert it into a different table.
The SELECT INTO statement is the most frequently used to create a backup copy of the table.
The SQL syntax that you selected
We can select all columns to the new table:
Select *
into New_table_name [in Externaldatabase]
from Old_tablename
or we can select only columns we're going to the new table: Select Column_ Name (s)
into new_table_name [in Externaldatabase]
the From old_tablename database is selected for example to make a backup copy-now we want to accurately replicate the data in our "people" seating. We use the following SQL statement: SELECT *
into Persons_backup
The from Persons can do the same. SELECT *
into persons_backup in ' Backup.mdb '
From Persons we can also replicate only a few areas into the new table: Select Lastname,firstname
into Persons_backup
from Persons to the database selection-with a W Here clause we can also add a WHERE clause. The following statement creates a "persons_backup" table, and only the people who live in the city "Sandnes": Select Lastname,firstname
into Persons_backup
from Persons
where city= ' Sandnes ' into the database selection-join table selection data from more than one table is also possible. The following example creates a "persons_order_backup" table that contains data from two tables "people" and "orders": SELECT Persons.lastname,orders.orderno
into Persons_order_ Backup
from Persons
INNER JOIN Orders
on persons.p_id=orders.p_id