但行好事
莫论前程❤

Oracle学习笔记—insert into select

语法:

insert into table_name1 select 字段 from table_name2 WHERE

insert into table_name1(字段1,字段2) select 字段1,字段2 from table_name2 WHERE 

示例

INSERT INTO EPRK_PERSONCONTR_V
  SELECT PK_PERSONCONTR,
         PK_CONTRLIST,
         PK_PERSON,
         V_COMPANY_NOTTAX,
         PK_ORG,
         TS,
         PERSONAL_TAX,
         0,
         COMPANY_TAX,
         0,
         V_PERSONAL_TAX,
         V_PERSONAL_NOTTAX,
         V_COMPANY_TAX,
         V_COMPANY_NOTTAX,
         PERSON_ADVANT,
         PERSON_TAXED,
         PERSON_GENERAL,
         CORP_ADVANT,
         CORP_TAXED,
         CORP_GENERAL,
         V_PERSONAL_OFFICE,
         V_COMPANY_OFFICE,
         CONTR_STATE,
         CONTR_CASH,
         PK_CONTR_TYPE,
         MEMO,
         PLAN_DATE,
         WRITEN_OFF,
         PSN_WRITTEN_OFF,
         CORP_WRITTEN_OFF,
         AAE180,
         AAE003,
         PERSONAL_NOTTAX_L,
         COMPANY_NOTTAX_L,
         V_COMPANY_NOTTAX_L,
         CONTR_TOTAL_L
    FROM EPRK_PERSONCONTR EPC
   WHERE EXISTS (SELECT 1
            FROM EPRK_CONTRLIST CON
           WHERE CON.PK_CONTRLIST = EPC.PK_CONTRLIST
             AND CON.ARRIVED_STATUS <> 3
             AND CON.CONTR_START_PERIOD >= 'start_date'
             AND CON.CONTR_END_PERIOD <= 'end_date'
             AND CON.PK_CORPORATION IN ('value_pk_corporation'))
     AND EPC.V_COMPANY_NOTTAX > 0
     AND EPC.PK_PERSON = 'pk_person_value'

赞(0) 打赏
未经允许不得转载:刘鹏博客 » Oracle学习笔记—insert into select
分享到: 更多 (0)

评论 抢沙发

评论前必须登录!

 

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏