SELECT INTO 语句
SELECT INTO 语句常用于创建表的备份复件或者用于对记录进行存档。
语法:
SELECT column_name(s) INTO newtable [IN externaldatabase]
FROM source
制作备份复件
下面的例子会制作"Persons"表的备份复件:
SELECT * INTO Persons_backup
FROM Persons
IN子句可用于向另一个数据库中拷贝表:
SELECT Persons.* INTO Persons IN 'Backup.mdb'
FROM Persons
如果我们希望拷贝某些域,可以在SELECT语句后列出这些域:
SELECT LastName,FirstName INTO Persons_backup
FROM Persons
你也可以添加WHERE子句。下面的例子通过从"Persons表中提取居住在"Sandnes"的人的信息,创建了一个带有两个列的名为"Persons_backup"的表:
SELECT LastName,Firstname INTO Persons_backup
FROM Persons
WHERE City='Sandnes'
从超过一个表中选取数据也是可以做到的。下面的例子会创建一个名为"Empl_Ord_backup"的新表,其中包含了从Employees和Orders两个表中取得的信息:
SELECT Employees.Name,Orders.Product
INTO Empl_Ord_backup
FROM Employees
INNER JOIN Orders
ON Employees.Employee_ID=Orders.Employee_ID