第1个回答 2013-04-17
创建两个表,Students 为A表,Students _Temp为B表,从A表取ID,UserName插入到B表中。第一,A表--Students CREATE TABLE [Students] (
[ID] [int] NOT NULL ,
[UserName] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[Age] [int] NULL ,
[Sex] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
CONSTRAINT [PK_Students] PRIMARY KEY CLUSTERED
(
[ID]
) ON [PRIMARY]
) ON [PRIMARY] --B表CREATE TABLE [Students_Temp] (
[ID] [int] NOT NULL ,
[UserName] [varchar] (20) COLLATE Chinese_PRC_CI_AS NULL ,
[Age] [int] NULL ,
[Sex] [char] (10) COLLATE Chinese_PRC_CI_AS NULL ,
CONSTRAINT [PK_Students2] PRIMARY KEY CLUSTERED
(
[ID]
) ON [PRIMARY]
) ON [PRIMARY] 第二,A表插入实验数据insert into Students values (1,'zhangsan1',19,'man')
insert into Students values (2,'zhangsan2',19,'man')
insert into Students values (3,'zhangsan3',19,'man')
insert into Students values (4,'zhangsan4',19,'man')
insert into Students values (5,'zhangsan5',19,'man')
insert into Students values (6,'zhangsan6',19,'man')
insert into Students values (7,'zhangsan7',19,'man')
insert into Students values (8,'zhangsan8',19,'man') 第三,执行A表取数据插到B表中操作insert into Students_Temp(ID,UserName) select ID,UserName from Students 最后,查看B表Students_Temp中的数据select * from students_Temp
第3个回答 2013-04-17
sqlserver中SELECT COL1,COL2,COL3 INTO NEWTABLE FROM TABLE WHERE ......oracle中CREATE TABLE NEWTABLE AS SELECT COL1,COL2,COL3 FROM TABLE WHERE ....