SQL SELECT INTO tutorial
The SQL SELECT INTO statement can be used to create a backup copy table.
In the SQL SELECT INTO statement
In the select into statement, SELECT data from a table and insert it to a different table.
The select into statement is the table most frequently used to create backup copies.
Selected SQL syntax
We can select all columns to the new table:
SELECT *INTO new_table_name [IN externaldatabase] FROM old_tablename
Or we can select only the columns for the new table:
SELECT column_name(s)INTO new_table_name [IN externaldatabase] FROM old_tablename
Select database to Example
Make backup copies-now we want to accurately copy the data at our "people" seat.
We use the following SQL statement
SELECT *INTO Persons_BackupFROM Persons
We can also use the clause to copy the table to another database:
SELECT *INTO Persons_Backup IN 'Backup.mdb'FROM Persons
Or we can do the same.
SELECT LastName,FirstNameINTO Persons_BackupFROM Persons
Go to database selection-with a w here clause
We can also add a WHERE clause.
The following statement creates a "Persons_Backup" table. Only the persons who live in the city "Sanes ":
SELECT LastName,FirstnameINTO Persons_BackupFROM PersonsWHERE City='Sandnes'
Choose database> Add Table
It is also possible to select data from more than one table.
The following example creates a "Persons_Order_Backup" table that contains data from two tables: "person" and "order ":
SELECT Persons.LastName,Orders.OrderNoINTO Persons_Order_BackupFROM PersonsINNER JOIN OrdersON Persons.P_Id=Orders.P_Id