1、-- Create table
create table TEST
(
TEST DATE
)tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
2、-- Create procedure
create or replace procedure pro_test
AS
carinfo_id number;
BEGIN
insert into test values(SYSDATE);
commit;
end pro_test;
3、-- Create 作业 每隔1分钟 执行一次
VARIABLE jobno number;
begin
DBMS_JOB.SUBMIT(:jobno,'pro_test;',SYSDATE,'sysdate+1/24/12');
commit;
end;
/
-- Create 作业 每隔10秒执行一次
VARIABLE jobno number;
begin
DBMS_JOB.SUBMIT(:jobno,'pro_test;',SYSDATE,'sysdate+1/24/60/10');
commit;
end;
/
4、删除job
exec dbms_job.remove(21);
5、查看所有job;
select * from dba_jobs;
6、查看正在运行的job;
select * from dba_jobs_running;
7、根据sid查出对应的session;
select SID,SERIAL# from V$Session where SID='&SID';
8、kill对应的session;
alter system kill session '&SID,&SERIAL';
9、将job置为broken;
exec dbms_job.broken('&JOB',true);
10、sysdba用户权限删除job;
delete from dba_jobs where JOB='&JOB';
interval设置:
每隔一天 'SYSDATE + 1'
每隔7天 'SYSDATE + 7'
每隔一个小时 'SYSDATE + 1/24'
10分钟 'SYSDATE + 10/1440'
30秒 'SYSDATE + 30/86400'
每月2号凌晨1点执行 TRUNC(LAST_DAY(SYSDATE))+2+1/24
http://hi.baidu.com/99408494/blog/item/757a6faafc0c52f71e17a21d.html
http://blog.csdn.net/jingxiangren/archive/2009/05/08/4159932.aspx