ORACLE 将一个库的部分值带条件插入到另外一个库
发布时间:2020-12-12 13:42:14 所属栏目:百科 来源:网络整理
导读:将一个表插入另外一个表,两种方法: 1.insert into table1?select * from table2 ;?或者2.create table1 as select * from table2 ; 第一种方法适合表1和表2的字段完全相同,如果有部分不同 ?字段的顺序一定要和表1的一致,名称可以不一致。即使没有的数字
将一个表插入另外一个表,两种方法: 1.insert into table1?select * from table2 ;?或者2.create table1 as select * from table2 ; 第一种方法适合表1和表2的字段完全相同,如果有部分不同 ?字段的顺序一定要和表1的一致,名称可以不一致。即使没有的数字,可以用序列或者函数。例如: insert into table1 t1 select CRMII.SEQ_HX_WRZGBD.NEXTVAL as id,--序列 zqdm as gpbh,--字段1 zqmc as gpmc,--字段2 syl_lj as ljsyl,--字段3 sysdate as cjsj --系统时间 from (select SYL_LJ,zqmc,zqdm from (select zqmc,zqdm,max(syl_lj) as syl_lj from (select ZQMC,ZQDM,SYL_LJ from TETG_CP_JG_TJGP where TJRQ between to_number(to_char(sysdate - 100,‘yyyymmdd‘)) and to_number(to_char(sysdate,‘yyyymmdd‘)) --修改函数 --and YTJCP_MC LIKE ‘%热点%‘ 模糊查询 and SYL_LJ is not null) group by (zqmc,zqdm)) --去重 order by SYL_LJ desc) --排序 where rownum <= 3; --返回条数 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |