Create oracle scheduler job which runs daily

99封情书 提交于 2021-02-07 18:32:07

问题


I want to create oracle scheduler job which runs daily at 20:00 and runs for 30 minute. This job will delete the rows from KPI_LOGS table as this table contains large amount of data and it continues to grow. I have created the below script in oracle sql developer for such job but not sure if this is correct or not as i am new to scheduler job concept.

    BEGIN
        DBMS_SCHEDULER.CREATE_JOB (
                job_name => '"RATOR_MONITORING"."CROP_KPI_LOGS"',
                job_type => 'PLSQL_BLOCK',
                job_action => 'DELETE FROM KPI_LOGS WHERE CAST(TIMESTAMP AS DATE) < (SYSDATE  - 28);',
                number_of_arguments => 0,
                start_date => NULL,
                repeat_interval => 'FREQ=DAILY;INTERVAL=30',
                end_date => NULL,
                enabled => FALSE,
                auto_drop => FALSE,
                comments => 'CROP_KPI_LOGS');    

        DBMS_SCHEDULER.SET_ATTRIBUTE( 
                 name => '"RATOR_MONITORING"."CROP_KPI_LOGS"', 
                 attribute => 'logging_level', value => DBMS_SCHEDULER.LOGGING_OFF);



    DBMS_SCHEDULER.enable(
             name => '"RATOR_MONITORING"."CROP_KPI_LOGS"');
END;

回答1:


the repeat_internal is incorrect, what you have there will run every 30 days. to run at 8pm each day go for...

FREQ=DAILY; BYHOUR=20

you can't dictate how long it will run for, it will take as long as your DELETE statement takes



来源:https://stackoverflow.com/questions/31678532/create-oracle-scheduler-job-which-runs-daily

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!