千家信息网

oracle业务优化求助,在组合分区表中求本月与上月重复部分

发表于:2024-12-03 作者:千家信息网编辑
千家信息网最后更新 2024年12月03日,with cur_month as(select *from CUST_SFM_JYCRMEPC_LISTwhere mold = '302'and create_time >=to_date(to_
千家信息网最后更新 2024年12月03日oracle业务优化求助,在组合分区表中求本月与上月重复部分

with cur_month as

(select *

from CUST_SFM_JYCRMEPC_LIST

where mold = '302'

and create_time >=

to_date(to_char(sysdate, 'yyyy/mm') || '/01', 'yyyy-mm-dd')

and create_time <

to_date(to_char(last_day(sysdate), 'yyyy/mm/dd'), 'yyyy-mm-dd') + 1),

pre_month as

(select *

from CUST_SFM_JYCRMEPC_LIST

where mold = '302'

and create_time >=

to_date(to_char(ADD_MONTHS(sysdate, -1), 'yyyy/mm') || '/01',

'yyyy-mm-dd')

and create_time <

to_date(to_char(last_day(ADD_MONTHS(sysdate, -1)), 'yyyy/mm/dd'),

'yyyy-mm-dd') + 1)

insert /*+append parallel(t,4)*/ --月新增

into CUST_SFM_JYCRMEPC_LIST t

select PROVICE_CODE,

MDN,

IMSI,

PAYMENT_MODE_CD,

PROD_INST_STATE,

STATE_TIME,

REGION,

EMDN,

EIMSI,

EPAYMENT_MODE_CD,

EPROD_INST_STATE,

ESTATE_TIME,

EREGION,

302B mold,

sysdate CREATE_TIME

from (select PROVICE_CODE,

MDN,

IMSI,

PAYMENT_MODE_CD,

PROD_INST_STATE,

STATE_TIME,

REGION,

EMDN,

EIMSI,

EPAYMENT_MODE_CD,

EPROD_INST_STATE,

ESTATE_TIME,

EREGION

from cur_month

minus

select PROVICE_CODE,

MDN,

IMSI,

PAYMENT_MODE_CD,

PROD_INST_STATE,

STATE_TIME,

REGION,

EMDN,

EIMSI,

EPAYMENT_MODE_CD,

EPROD_INST_STATE,

ESTATE_TIME,

EREGION

from pre_month)


CUST_SFM_JYCRMEPC_LIST 该表示组合分区表,以CREATE_TIME

为主分区, mold 为子分区,我要实现的业务是,用 CUST_SFM_JYCRMEPC_LIST表中本月的减去上月的,求出新增的,然后将新增的插入到 CUST_SFM_JYCRMEPC_LIST 表, 请教一下有什么比较好的方法不用写的这么累呢



0