SQL Tutorial: SQL SELECT INTO instance 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 column to which we want to go to the new table: SELECT column_name (s)
INTO new_table_name [IN externaldatabase]
FROM old_tablename database select to make backup copy for example-now, we want to accurately copy the data at our "people" seat. We use the following SQL statement: SELECT *
INTO Persons_Backup
FROM Persons can also be like this. SELECT *
INTO Persons_Backup IN 'backup. mdb'
FROM Persons, we can also copy tables that only have a few fields to enter the new table: SELECT LastName, FirstName
INTO Persons_Backup
FROM 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 one person lives in the city "Sanes": SELECT LastName, Firstname
INTO Persons_Backup
FROM Persons
WHERE City = 'sandes' it is also possible to enter database selection-Add Table 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. OrderNo
INTO Persons_Order_Backup
FROM Persons
Inner join Orders
ON Persons. P_Id = Orders. P_Id