ORACLE 手动添加时间分区

declare
  V_DATE VARCHAR2(8);
  CURSOR IV_DATE IS SELECT TO_CHAR(TO_DATE('20190903','YYYYMMDD')+LEVEL-1,'YYYYMMDD') AS 日期时间段 FROM DUAL CONNECT BY LEVEL <= TO_DATE('20200101','YYYYMMDD')-TO_DATE('20190903','YYYYMMDD');
BEGIN
    open IV_DATE;
    LOOP 
        fetch IV_DATE into V_DATE; 
        execute immediate 'ALTER TABLE TB_ACCEPT_JOB_D ADD PARTITION P_'|| V_DATE || ' VALUES ('''|| V_DATE || ''')';
        
    END LOOP;
    close IV_DATE;    
END;

 

posted @ 2019-09-01 17:01  flashman126  阅读(1473)  评论(0编辑  收藏  举报