oracle创建job方法
alter system enable restricted session;
--创建表
create table G_TEST
(
ID NUMBER(12),
C_DATE DATE
)
select * from G_TEST
--创建插入数据时增长的ID号
create sequence G_SEQ
minvalue 1
maxvalue 999999999999999999999999999
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;
--新建JOB
declare
job number;
begin
sys.dbms_job.submit(job,'prc_g_test;',sysdate,'sysdate+1/1440');
end;
SELECT * FROM DBA_JOBS;
select * from user_jobs;
--启动JOB参数为job号
begin
--dbms_job.run(44); --启动JOB
dbms_job.broken(44,false,sysdate); --停止JOB
end;
select count(*) from g_test
--查看正在运行的JOB
select * from dba_jobs_running;