SELECT INTO命令從一個表中復制數(shù)據(jù),并將其插入到新表中。
以下SQL語句創(chuàng)建客戶的備份副本:
SELECT * INTO CustomersBackup2017 FROM Customers;
以下SQL語句使用IN子句將表復制到另一個數(shù)據(jù)庫中的新表中:
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語句將數(shù)據(jù)從多個表復制到新表中:
SELECT Customers.CustomerName, Orders.OrderID INTO CustomersOrderBackup2017 FROM Customers LEFT JOIN Orders ON Customers.CustomerID = Orders.CustomerID;