SELECT INTO命令从一个表中复制数据,并将其插入到新表中。
以下SQL语句创建客户的备份副本:
SELECT * INTO CustomersBackup2017 FROM Customers;
以下SQL语句使用IN子句将表复制到另一个数据库中的新表中:
SELECT * INTO CustomersBackup2017 IN 'Backup.mdb' FROM Customers;
以下SQL语句仅将几列复制到新表中:
SELECT CustomerName, ContactName INTO CustomersBackup2017 FROM Customers;
以下SQL语句仅将德国客户复制到新表中:
SELECT * INTO CustomersGermany FROM Customers WHERE Country = 'Germany';
以下SQL语句将数据从多个表复制到新表中:
SELECT Customers.CustomerName, Orders.OrderID INTO CustomersOrderBackup2017 FROM Customers LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID;