oracle定时任务

oracle定时任务

1.创建根据日期删除的过程,
create or replace procedure teacherjob is
begin   
delete from zftal_mobilehd_txrzb where txsj like  (select 
to_char(add_months(sysdate,-1),'yyyymm%') from dual);
delete from zftal_mobilehd_hdwtxqb where hdsj like  (select 
to_char(add_months(sysdate,-1),'yyyymm%') from dual);
end;
2.新建定时任务并提交(参考网址:[https://www.cnblogs.com/yx007/p/6519544.html]
(https://www.cnblogs.com/yx007/p/6519544.html)
user_jobs表结构
字段(列) 类型 描述
job number 任务的唯一标示号
log_user varchar2(30) 提交任务的用户
priv_user varchar2(30) 赋予任务权限的用户
schema_user varchar2(30) 对任务作语法分析的用户模式
last_date date 最后一次成功运行任务的时间
last_sec varchar2(8) 如hh24:mm:ss格式的last_date日期的小时,分钟和秒
this_date date 正在运行任务的开始时间,如果没有运行任务则为null
this_sec varchar2(8) 如hh24:mm:ss格式的this_date日期的小时,分钟和秒
next_date date 下一次定时运行任务的时间
)
TRUNC(LAST_DAY(SYSDATE))+15+14.2/24
每个月的15号14.2时执行

3.查看定时任务执行时间和日期:SELECT * FROM dba_jobs;
4.跟踪任务的情况(查看任务队列):select job, next_date, next_sec, failures, broken from user_jobs;

posted @ 2021-09-07 16:25  kht  阅读(168)  评论(0编辑  收藏  举报