Username: Password:

SQL Select Into语句
来源: 未知 作者: 未知 发布时间:2008-04-15 00:00:00

The SELECT INTO Statement
SELECT INTO 语句

The SELECT INTO statement is most often used to create backup copies of tables or for archiving records.
SELECT INTO语句常用来给数据表建立备份或是历史档案。

Syntax
语法

SELECT column_name(s) INTO newtable [IN externaldatabase] FROM source


Make a Backup Copy
制作一个备份

The following example makes a backup copy of the "Persons" table:
下面的例子中会为"Persons"表制作一个备份

SELECT * INTO Persons_backupFROM Persons

The IN clause can be used to copy tables into another database:
IN子句能够用来将多个数据表拷贝到另一个数据库上:

SELECT Persons.* INTO Persons IN ’Backup.mdb’FROM Persons

If you only want to copy a few fields, you can do so by listing them after the SELECT statement:
假如您仅仅想拷贝其中的一部分,能够在SELECT后面列举出他们:

SELECT LastName,FirstName INTO Persons_backupFROM Persons

You can also add a WHERE clause. The following example creates a "Persons_backup" table with two columns (FirstName and LastName) by extracting the persons who lives in "Sandnes" from the "Persons" table:
您还能够加上WHERE子句。在下面的举例中会建立一个"Persons_backup"表,里面包含了在"Persons"表中住在"Sandnes"的个人姓(LastName)和名(FirstName)信息。

SELECT LastName,Firstname INTO Persons_backupFROM PersonsWHERE City=’Sandnes’

Selecting data from more than one table is also possible. The following example creates a new table "Empl_Ord_backup" that contains data from the two tables Employees and Orders:
选择多个表进行备份也是能够的。下面的举例就建立了一个新的表"Empl_Ord_backup"里面的数据就有Employees和Orders这两张表的内容:

SELECT Employees.Name,Orders.ProductINTO Empl_Ord_backupFROM EmployeesINNER JOIN OrdersON Employees.Employee_ID=Orders.Employee_ID

喜欢本文,那就收藏到:

    Del.icio.us Google书签 Digg Live Bookmark Technorati Furl Yahoo书签 Facebook 百度搜藏 新浪ViVi 365Key网摘 天极网摘 和讯网摘 博拉网 POCO网摘 添加到饭否 QQ书签 Digbuzz我挖网
相关评论  我也要评论
还没有关于此文章的相关评论!
  • 昵称: (为空则显示guest)
  • 评论分数: ★ ★ ★★★ ★★★★ ★★★★★
  • 评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
  • 导航
    赞助商
    文章类别
    订阅