1. 復(fù)制表結(jié)構(gòu)及其數(shù)據(jù): create table table_name_new as select * from table_name_old
2. 只復(fù)制表結(jié)構(gòu): create table table_name_new as select * from table_name_old where 1=2;
或者: create table table_name_new like table_name_old
3. 只復(fù)制表數(shù)據(jù):
如果兩個(gè)表結(jié)構(gòu)一樣:insert into table_name_new select * from table_name_old
如果兩個(gè)表結(jié)構(gòu)不一樣:insert into table_name_new(column1,column2...)
select column1,column2... from table_name_old
完全COPY另一張表
create table aa as select * from and05
將結(jié)果集的數(shù)據(jù)插入到某表中
insert into and07(cnd215,cnd224,cnd222,cnd225) select z.cnd215,sysdate,
(select sum(cnd037) from and02 a where a.cnd032='20002901' and a.cnd215=z.cnd215) A,
(select sum(cnd037) from and02 a where a.cnd032='20002902' and a.cnd215=z.cnd215) B
from and02 z where trunc(cne007,'mm') = trunc(sysdate,'mm') group by cnd215
針對(duì)“完全COPY另一張表”的演練
truncate table aa
insert into aa select * from and05;
用另一個(gè)表的結(jié)果去更新某張表
update and02 a set a.and07id=(select b.and07id from and07 b where a.cnd215=b.cnd215 and trunc(cnd224,'mm')=trunc(sysdate,'mm'));