創(chuàng)建表,復(fù)制內(nèi)容結(jié)構(gòu)

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'));
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容