select into是把选中的内容存到一张新表里面,可以复制整张表,也可以选几列
- 比如,把表复制到另一个数据库里:
SELECT *
INTO WebsitesBackup2016 IN 'Backup.mdb'
FROM Websites;
- 只复制中国的网站插入到新表中:
SELECT *
INTO WebsitesBackup2016
FROM Websites
WHERE country='CN';
- 复制多个表中的数据插入到新表中:
SELECT Websites.name, access_log.count, access_log.date
INTO WebsitesBackup2016
FROM Websites
LEFT JOIN access_log
ON Websites.id=access_log.site_id;
Insert into
对现有的表插入一些数据,数据来源于其他现有的表
- 复制id=1 的 APP的名字,国家 到 "Websites" 中:
INSERT INTO Websites (name, country)
SELECT app_name, country FROM apps
WHERE id=1;