首页 > 代码库 > 15.select into

15.select into

select into
SELECT INTO 语句从一个表中选取数据,然后把数据插入另一个表中。

SELECT INTO 语句常用于创建表的备份复件或者用于对记录进行存档。

CREATE TABLE mdb(
   Id_P   INT              NOT NULL,
   LastName VARCHAR (20)     NOT NULL,
   FirstName VARCHAR (20)     NOT NULL,
   Address  CHAR (25),
   City     CHAR (25),
   PRIMARY KEY (Id_P)
);

CREATE TABLE Persons_backup(
   LastName VARCHAR (20)     NOT NULL,
   FirstName VARCHAR (20)
);


SELECT *
INTO Persons IN ‘test.mdb‘
FROM Persons

SELECT LastName,FirstName
INTO Persons_backup
FROM Persons

15.select into