oracle 创建 job

-----创建表-----
create table G_TEST
(  cid     NUMBER(12),
   c_date  timestamp
)
-----创建序列----
create sequence G_SEQ
minvalue 1
maxvalue 999999999999
start with 141
increment by 1
cache 20;
----创建存储过程-------
create or replace procedure prc_g_test is
begin
insert into g_test values(g_seq.nextval,sysdate);
end prc_g_test;
------执行脚本---
variable job_num number;
begin
    sys.dbms_job.submit(job => :job_num,
    what => 'prc_g_test;',
    next_date => to_date('2013-01-04 14:10:', 'yyyy-mm-dd hh24:mi:ss'),
    interval => 'sysdate+1/1440');--每天1440分钟,即一分钟运行test过程一次
    commit;
end;
----查询jobnum----
select * from dba_jobs;
--移除job脚本-
begin
dbms_job.remove(53);
commit;
end;

猜你喜欢

转载自wangtianhui.iteye.com/blog/1759592
今日推荐