The new Oracle Scheduler offers far more functionality than the DBMS_JOB package.
Link to Oracle® Database PL/SQL Packages and Types Reference 11g Release 1 (11.1):
http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_sched.htm
从10g开始,DBMS_SCHEDULER 逐步会替换掉 DBMS_JOB,下面是它们的区别及其替换的理由。
DBMS_JOB has been around forever, and now it is deprecated. Although DBMS_JOB still exists in 10g and 11g, but only for backward compatibility. No new features are being added to dbms_job and you will likely quickly run into its limitations. Oracle recommends the use of DBMS_SCHEDULER in releases 10g and up. DBMS_SCHEDULER is a much more robust package and fully-featured than DBMS_JOB. To use the DBMS_SCHEDULER package a user must be granted the CREATE JOB privilege.
DBMS_SCHEDULER includes the following features that DBMS_JOB does not have :
- logging of job runs (job history)
- simple but powerful scheduling syntax (similar to but more powerful than cron syntax)
- running of jobs outside of the database on the operating system
- resource management between different classes of jobs
- use of job arguments including passing of objects into stored procedures
- privilege-based security model for jobs
- naming of jobs and comments in jobs
- stored, reusable schedules
Features in releases after 10g Release 1 include :
- dependencies between job units (10gR2 and up)
- scheduling based on financial calendars and fiscal quarters (10gR2 and up)
- event based jobs which run when an event is received (10gR2 and up)
- running of jobs on remote machines (11gR1 and up)
- e-mail notifications on job events of interest (10gR2 and up)
- starting a job based on arrival of a file (10gR2 and up)
Here simple comparison for the codes :
- Old using DBMS_JOB scheduler.VARIABLE l_job NUMBER;
BEGIN
DBMS_JOB.submit (
job => :l_job,
what => ‘BEGIN NULL; /* code to execute*/ END;’,
next_date => SYSDATE,
interval => ‘SYSDATE + 1 /* 1 Day */’);COMMIT;
END;
/
PRINT l_job - New with DBMS_SCHEDULER scheduler.BEGIN
DBMS_SCHEDULER.create_job (
job_name => ‘dummy_job’,
job_type => ‘PLSQL_BLOCK’,
job_action => ‘BEGIN NULL; /* code to execute */ END;’,
start_date => SYSTIMESTAMP,
repeat_interval => ‘SYSTIMESTAMP + 1 /* 1 Day */’);
END;
/
After replace DBMS_JOB with DBMS_SCHEDULER for all jobs successful, the job_queue_processes parameter can now be set to zero.
SQL> alter system set job_queue_processes=0;
There is also a forum dedicated to questions about dbms_scheduler here : http://forums.oracle.com/forums/forum.jspa?forumID=193
from: http://pandazen.wordpress.com/2008/09/19/use-dbms_scheduler-to-replace-dbms_job/
--End--
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22198259/viewspace-667340/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/22198259/viewspace-667340/
本文详细对比了Oracle 10g中DBMS_SCHEDULER与DBMS_JOB的区别,阐述了DBMS_SCHEDULER在功能、性能及安全性上的优势,并提供了从DBMS_JOB向DBMS_SCHEDULER转换的具体步骤和代码示例。
408

被折叠的 条评论
为什么被折叠?



