11.07.2015 Views

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

162 CHAPTER 3 ■ DATABASE ADMINISTRATIONLightweight JobsA Scheduler job is a task you schedule to run one or more times. Jobs contain two things: theaction to be taken and its schedule. You can create a job by explicitly specifying the action to beperformed by the job and its schedule in the job definition itself, and you can also create a jobby using an existing program object and schedule object to specify the action and the frequency ofexecution.In <strong>Oracle</strong> <strong>Database</strong> 10g, there was simply only one type of job you could create. <strong>Oracle</strong><strong>Database</strong> <strong>11</strong>g lets you create two types of jobs: regular jobs and lightweight jobs. Regular jobsare the jobs supported by the Scheduler in <strong>Oracle</strong> <strong>Database</strong> <strong>11</strong>g. Regular jobs entail quite a bitof overhead, because they have to be created and dropped after each execution by the Scheduler.Regular jobs offer advantages such as the ability to use other users’ programs, and they offerfine-grained control over the privileges to run the job.A lightweight job inherits the privileges, and in some cases the job metadata itself, from ajob template. Lightweight jobs aren’t self-contained jobs like regular Scheduler jobs, since theyinherit the job characteristics from the job template. If the Scheduler needs to create and dropa large number of jobs every day, lightweight jobs are preferable to regular jobs. Use regularjobs for tasks that you need to execute infrequently. Lightweight jobs, since they aren’t databaseobjects, don’t cause overhead by having to create and drop them. In addition, they arefaster to create and need less space for storing their metadata.You create a lightweight job by using the create_job procedure of the DBMS_SCHEDULERpackage. In addition to the usual arguments that you must supply to create a regular job, youalso specify the value LIGHTWEIGHT for the new attribute job_style. You don’t have to specifythe job_style attribute when creating a regular job. The following example shows how tocreate a lightweight job by specifying a program as a job template.The following statement creates a lightweight job that uses the program test_prog as a jobtemplate:begindbms_scheduler.create_job (job_name => 'lightweight_job1',template => 'test_prog',repeat_interval => 'freq=daily;by_hour=9',end_time => '30-DEC-07 12.00.00 AMAustralia/Sydney',job_style => 'LIGHTWEIGHT',comments => 'New lightweight job’);end;/In the example, the template attribute refers to the program (or stored procedure) thatcontains the job action. Note that you must use a job template when creating a lightweight job.That is, you can’t create a lightweight job that contains all the information in the job creationstatement itself. You also can’t assign privileges directly in a lightweight job because the jobwill acquire or inherit the privileges from the job template.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!