--创建一次执行的匿名块任务,成功调用一次后job消失BEGINDBMS_SCHEDULER.CREATE_JOB (job_name => 'my_new_job2',job_type => 'PLSQL_BLOCK',job_action =>'BEGINfor i in 1 .. 5 loopinsert into t values (i);end loop;commit;END;');END;--创建存储过程代替匿名块里面的内容,对于数据量大的代码很方便create or replace procedure p_insert_tasBEGINfor i in 1 .. 5 loopinsert into t values (i);end loop;commit;END;BEGINDBMS_SCHEDULER.CREATE_JOB (job_name => 'my_new_job2',job_type => 'PLSQL_BLOCK',job_action => 'BEGIN p_insert_t; END;');END;--查看job的状态SELECT job_name, owner, program_name, program_owner, state, enabledFROM dba_scheduler_jobsWHERE owner NOT IN ('SYS', 'SYSTEM');SELECT *FROM dba_scheduler_jobsWHERE owner NOT IN ('SYS', 'SYSTEM');--执行job, enable job和run job两种方式都可以调用job--enable job之后自动执行jobBEGINDBMS_SCHEDULER.ENABLE ('my_new_job2');END;--run jobBEGINDBMS_SCHEDULER.RUN_JOB(JOB_NAME => 'my_new_job2',USE_CURRENT_SESSION => FALSE);END;--停止 jobBEGINDBMS_SCHEDULER.STOP_JOB('MY_NEW_JOB2');END;/--删除JOBBEGINDBMS_SCHEDULER.DROP_JOB ('MY_NEW_JOB2');END;