oracle創建三個定時任務,每個小時調用一次REPORT_HOUR,每天調用一次REPORT_DAY,每個月調用一次REPORT_MONTH
declare job1 number; job2 number; job3 number; begin sys.dbms_job.submit(job => job1, what => 'REPORT_HOUR;', next_date => to_date('01-01-2014 00:00:00', 'dd-mm-yyy hh24:mi:ss'), interval => 'sysdate+1/24'); sys.dbms_job.submit(job => job2, what => 'REPORT_DAY;', next_date => to_date('01-01-2014 00:00:00', 'dd-mm-yyy hh24:mi:ss'), interval => 'sysdate+1'); sys.dbms_job.submit(job => job3, what => 'REPORT_MONTH;', next_date => to_date('01-01-2014 00:00:00', 'dd-mm-yyy hh24:mi:ss'), interval => 'TRUNC(LAST_DAY(SYSDATE)+1)'); end;創建完成後,可通過查詢dba_jobs表查詢當前數據庫的定時任務。
select * from dba_jobs刪除定時任務,通過上一條語句查詢要刪除任務的JOB字段值,通過此值來刪除對應任務。
sys.dbms_job.remove(job1);