两种表复制语句

第一种:insert into table ()  select

例子:

Insert into Table2(a, c) select a,c from Table1

 

第二种:select  into  from 语句

在sqlserver中:

语句形式为:SELECT vale1, value2 into Table2 from Table1
要求目标表Table2不存在,因为在插入时会自动创建表Table2,并将Table1中指定字段数据复制到Table2中 。
例子:
select a,c INTO Table2 from Table1
 
在Oracle中:不能直接使用这句话,在PL/SQL中实现该功能,可使用Create table newTable as select * from ...:
例子:
create TABLE Table1 
( 
    a varchar(10), 
    c varchar(10)
)

create table Table2 as
select a,c from Table1

 

posted @ 2017-10-11 13:55  美好的明天  阅读(398)  评论(0)    收藏  举报