引用
https://www.cnblogs.com/hoojo/p/oracle_procedure_job_interval.html
创建测试表
create table t_test_renbing(
current_time timestamp
);
创建测试用存储过程
create or replace procedure pro_job_test_renbing
as
begin
--dbms_output.put_line('系统时间:' || to_char(sysdate, 'dd-mm-yyyy hh24:mi:ss'));
insert into t_test_renbing values(sysdate);
commit;
end;
运行过程,进行测试
begin
pro_job_test_renbing;
commit;
end;
创建job,将job注册到dba_jobs表中定时启动job调用存储过程
declare
job1 number; --此处自动生成jobid
begin
dbms_job.submit(job1, 'pro_job_test_renbing;', sysdate, 'sysdate+20/(246060)');--每10秒插入一条记录
commit;
end;
查询job视图
select * from dba_jobs;
select * from all_jobs;
select * from user_jobs;
查询运行中的job
select * from dba_jobs_running;
运行job
begin
dbms_job.run(464);--和select * from user_jobs; 中的job值对应,看what对应的过程
end;
删除job
begin
dbms_job.remove(463);--和select * from user_jobs; 中的job值对应,看what对应的过程
commit;
end;