zoukankan      html  css  js  c++  java
  • ORACLE 将一个库的部分值带条件插入到另外一个库

    将一个表插入另外一个表,两种方法:

    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;    --返回条数
  • 相关阅读:
    053-113
    053-262
    053-294
    053-494
    053-60
    053-105
    053-102
    053-218
    【转】LiveWriter插入高亮代码插件介绍 基于SyntaxHighighter
    windows live Writer test
  • 原文地址:https://www.cnblogs.com/xuhai/p/9888563.html
Copyright © 2011-2022 走看看