oracle job


create table TEST(a date);
   

create or replace procedure ocpyang
as
begin
insert into TEST values(sysdate);
end;
/


 
----每天凌晨执行

variable jobtest number;
begin
dbms_job.submit
(
job=>:jobtest,
what=>'OCPYANG;',
next_date=>sysdate,
Interval =>'TRUNC(sysdate+1)'
);  
end;
/



----每分钟执行一次


variable jobtest number;
begin
dbms_job.submit
(
job=>:jobtest,
what=>'OCPYANG;',
next_date=>sysdate,
Interval =>'TRUNC(sysdate,''mi'') + 1/ (24*60)'
);  
end;
/


----手动调用

--oracle新建job不是什么难事,简单示例!



begin
dbms_job.run(:jobtest);
end;
/




----查询执行结果


select to_char(a,'yyyy/mm/dd hh24:mi:ss') 时间 from TEST;
   

   -------------------
   2001/01/07 23:51:21
   2001/01/07 23:52:22
   2001/01/07 23:53:24


----删除JOB


begin
dbms_job.remove(:jobtest);
end;
/

你可能感兴趣的:(oracle job)