赞
踩
1.创建测试表
- CREATE TABLE SCHEDULE_JOB_TEST
- (
- R_ID VARCHAR2(10),
- R_DATE TIMESTAMP(6)
- );
2.创建定时任务
- BEGIN
- DBMS_SCHEDULER.CREATE_JOB(JOB_NAME => 'JOB_TEST',
- JOB_TYPE => 'PLSQL_BLOCK',
- JOB_ACTION => 'BEGIN
- INSERT INTO SCHEDULE_JOB_TEST VALUES ('' job '', SYSDATE);
- COMMIT;
- END;',
- ENABLED => TRUE,
- START_DATE => SYSTIMESTAMP,
- REPEAT_INTERVAL => 'SYSTIMESTAMP + 1/1440',
- --每分钟运行一次
- COMMENTS => 'rosanu_create_job');
- END;
3.查看运行结果
SELECT * FROM SCHEDULE_JOB_TSET;
1.查看已设置的定时任务
- SELECT * FROM USER_SCHEDULER_JOBS
- --WHERE JOB_ACTION LIKE '%SCHEDULE_JOB_TSET%'
- --Where语句可选条件,根据创建时语句设定,此处为JOB_ACTION包含存储过程
- ;
2.查看Job运行日志
- SELECT * FROM USER_SCHEDULER_JOB_LOG
- WHERE JOB_NAME = 'JOB_TEST'
- ORDER BY LOG_DATE DESC;
- BEGIN
-
- DBMS_SCHEDULER.SET_ATTRIBUTE('SCHEDULE_JOB_TEST','REPEAT_INTERVAL','TRUNC(SYSDATE) + 1 + 1/24');
- --修改为每天格林尼治时间一点钟
-
- END;
三个参数分别对应JOB_NAME,字段名,修改值
- BEGIN
- DBMS_SCHEDULER.DROP_JOB (
- JOB_NAME => 'JOB_TEST', -- JOB的名称
- FORCE => FALSE -- 是否强制删除JOB
- );
- END;
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。