Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Oracle Database 11g.pdf
Скачиваний:
78
Добавлен:
10.06.2015
Размер:
12.69 Mб
Скачать

Summary  607

LNE_JOB SCHEDULED

RAISE_JOB DISABLED

To view windows and their next start dates, the following SQL can be used:

SQL> select window_name, next_start_date

2from dba_scheduler_windows;

WINDOW_NAME

NEXT_START_DATE

--------------------

------------------------------------

WEEKNIGHT_WINDOW

12-OCT-04

10.00.00.300000 PM -08:00

WEEKEND_WINDOW

16-OCT-04

12.00.00.500000 AM -08:00

The DBA_SCHEDULER_JOB_LOG view can be used to view log entries for previously executed jobs, as shown here:

SQL> select log_id, trunc(log_date) log_date, owner, job_name, operation from dba_scheduler_job_log;

LOG_ID LOG_DATE

OWNER JOB_NAME

OPERATION

-------

----------

----- -----------------

---------

522 25-SEP-04

SYS

PURGE_LOG

RUN

524 25-SEP-04

SYS

ADV_SQL_TUNING

SUCCEEDED

525 25-SEP-04

SYS

ADV_SQL_TUNING

DROP

528 25-SEP-04

SYS

GATHER_STATS_JOB

RUN

484 18-SEP-04

SYS

GATHER_STATS_JOB

RUN

541 26-SEP-04

SYS

PURGE_LOG

RUN

543 27-SEP-04

SYS

PURGE_LOG

RUN

545 28-SEP-04

SYS

GATHER_STATS_JOB

RUN

546 28-SEP-04

SYS

PURGE_LOG

RUN

553 30-SEP-04

SYS

GATHER_STATS_JOB

RUN

622 10-OCT-04

SYS

LNE_JOB

RUN

549 29-SEP-04

SYS

GATHER_STATS_JOB

RUN

Summary

In this chapter, you learned about the new Oracle 11g Scheduler. You learned how it resolves issues such as schedule creep that existed in its predecessor, the DBMS_JOB package.

This chapter also explained the new architecture that underlies the Scheduler. You learned how the job table stores all enabled jobs within the database and how the job-coordinator process queries the job table on a regular basis and stores the job information in a memory

608  Chapter 12  n  Using the Scheduler to Automate Tasks

cache for faster access. When a job is scheduled to run, the job-coordinator process is automatically started (if it is not already active). It will pass the job information to a job-slave process for execution.

You learned that the job-slave process will gather all the metadata for the job, start a session as the owner of the job, begin a transaction within the session, and then execute the job. When the job completes, the slave commits the transaction and closes the session. The slave then updates the job entry in the job table to show a COMPLETE status. It inserts a new entry into the job log, updates the run count for the job, and then looks for any new work that needs to be done. If none is found, the job-slave process returns to a sleep state.

You also learned that, in a RAC environment, each instance has its own job coordinator, and the job coordinators have the ability to communicate with each other to keep information current. You learned that a RAC environment will still have only one job table that

is shared by all the instances. You also learned that jobs can be assigned to a service, as opposed to an instance, ensuring that the job can be run by a different node if an instance is down.

We showed you how, in a Data Guard environment, changes made to the primary are applied to the physical standby. For a logical standby, you have the option to run jobs based on the databases role—either primary or logical standby.

Next, you learned about job objects and how they are created and administered. You saw how the CREATE_JOB procedure is overloaded. You also learned to set job arguments using the SET_JOB_ARGUMENT_VALUE and the SET_JOB_ANYDATA_VALUE procedures as well as how to copy, run, disable, enable, and drop jobs.

We discussed program objects and how they define PL/SQL blocks, stored procedures, or external operating-system executables as well as their arguments and other metadata. You also learned to administer all aspects of program objects.

This chapter also covered schedule objects and how they are created. Schedules specify a start date, an optional end date, and a repeat interval. Together, these elements are used to calculate run dates. You can use the new calendaring syntax to define repeat intervals within the schedules.

You learned about lightweight jobs and the special conditions that may lead you to choose a lightweight job instead of a regular job.

Next you learned about job chains and how to create dependencies between job steps in a chain.

Finally, we discussed windows and how they can be used to switch resource plans at scheduled intervals to control resource allocation for the system. You learned that only one window can be open at any given time and that, when overlapping windows exist, a window with a priority of HIGH will take precedence over a window with a priority of LOW.

Exam Essentials 

609

Exam Essentials

Know how to simplify management tasks by using the Scheduler.    Understand how the Scheduler can be used to automate routine management tasks to run on a repeating basis. Know the types of programs that can be run through the Scheduler (PL/SQL blocks, stored procedures, and external operating-system executables).

Be able to create a job, program, schedule, and window.    Know the various CREATE procedures in the DBMS_SCHEDULER package (CREATE_JOB, CREATE_PROGRAM, CREATE_SCHEDULE, and CREATE_WINDOW). Understand the different options that can be used when creating a job (inline definitions versus stored objects). Understand that only a subset of attributes can be defined at creation time. The other attributes can be set by altering the object through the

SET_ATTRIBUTE and SET_ATTRIBUTE_NULL procedures.

Know how to create and use job chains.    Understand the difference between dependency rules, conditions, and actions. Know how to define chain steps. Know how to create a chain. Know how to add rules to a chain. Know how to enable, start, and stop a chain.

Know how to prioritize jobs.    Understand the difference between job class priorities and individual job priorities within a class. Know how to set a job attribute to change the job priority.

Know how to reuse Scheduler components for similar tasks.    Understand the difference between inline schedule and program definitions and stored Scheduler object components. Know that a job can reference stored schedule and program objects. Know that a window can reference a stored schedule object. Understand that a job can be reused with different parameters.

Understand how to view information about job executions and job instances.    Be aware of the different views available to view Scheduler information. Know that the views use the naming convention of DBA|ALL|USER_SCHEDULER_ as a prefix for all views (for example, DBA_SCHEDULER_JOBS, DBA_SCHEDULER_PROGRAMS, and so on). Know that the DBA_SCHEDULER_JOB_RUN_DETAILS view shows information about job executions and that the DBA_SCHEDULER_RUNNING_JOBS view shows information on jobs that are currently running.

610  Chapter 12  n  Using the Scheduler to Automate Tasks

Review Questions

1.When setting arguments for a job, which procedure do you use for types that cannot be implicitly converted to and from a VARCHAR2 datatype?

A.SET_JOB_ARGUMENT_VALUE

B.SET_JOB_VALUE_ANYDATA

C.SET_JOB_ANYDATA_VALUE

D.SET_SPECIAL_JOB_VALUE

E.SET_JOB_ANYTYPE_VALUE

2.Which DBMS_SCHEDULER procedures can be used to enable a program? (Choose all that apply.)

A.ENABLE

B.ENABLE_PROGRAM

C.VALIDATE_PROGRAM

D.SET_ATTRIBUTE

E.SET_ENABLED

3.Which of the following is not a valid calendaring syntax element?

A.FREQ

B.BYHOUR

C.RUNDATE

D.INTERVAL

E.BYMINUTE

4.Which Scheduler view(s) can be queried to see which jobs are currently executing? (Choose all that apply.)

A.DBA_SCHEDULER_JOB_RUN_DETAILS

B.DBA_SCHEDULER_RUNNING_JOBS

C.DBA_SCHEDULER_CURRENT_JOBS

D.DBA_SCHEDULER_JOBS

E.DBA_SCHEDULER_EXECUTING_JOBS

5.A schedule defined entirely within the confines of a Scheduler job object is known as a(n)

___________________.

A.Fixed schedule

B.Inline schedule

C.Stored schedule

D.Hard-coded schedule

E.None of the above

Review Questions 

611

6.Which DBMS_SCHEDULER procedure(s) can be used to alter an existing job? (Choose all that apply.)

A.SET_ATTRIBUTE_NULL

B.ALTER_JOB

C.ALTER_JOB_PARAMETERS

D.ALTER

E.SET_ATTRIBUTE

7.What is the default value for the ENABLED attribute of a job or program when it is created?

A.TRUE

B.FALSE

C.There is no default. It must be defined at creation time.

D.PENDING

E.NULL

8.To set the history retention period for either window logging or job logging individually, which parameters of the SET_SCHEDULER_ATTRIBUTE procedure need to be used? (Choose all that apply.)

A.LOG_HISTORY

B.JOB_LOG_RETENTION

C.WINDOW_LOG_RETENTION

D.WHICH_LOG

E.LOG_NAME

9.Consider the following code snippet:

BEGIN DBMS_SCHEDULER.SET_ATTRIBUTE (

name => ‘lne_job1’, attribute => ‘job_priority’, value => 1);

END;

/

If this code were executed, which of the following statements would be true?

A.The priority of the lne_job1 job would be set to 1.

B.The lne_job1 job would be executed synchronously.

C.The lne_job1 job would run immediately in the user’s current session.

D.The lne_job1 job would retain its current priority.

E.The job will immediately take priority over all running jobs.

612  Chapter 12  n  Using the Scheduler to Automate Tasks

10.Which of the following calendaring syntax expressions would evaluate to the last day of every month?

A.FREQ = MONTHLY; BYMONTHDAY = 31

B.FREQ = MONTHLY; BYMONTHDAY = -1

C.FREQ = DAILY; BYDAY = -1

D.FREQ = MONTHLY; BYDAY = 31

E.FREQ = DAILY; BYMONTHDAY = LAST_DAY

11.Which of the following tasks is not performed by the job coordinator?

A.Update job log when a job completes

B.Spawn and remove job slaves

C.Write/read job info to/from memory cache

D.Query job table

E.Pass job information to job slaves

12.Which of the following objects can be directly referenced by a window object? (Choose all that apply.)

A.Schedule object

B.Program object

C.Job object

D.Resource plan

E.Resource consumer group

13.Which of the following are valid program types for a lightweight job? (Choose all that apply.)

A.PLSQL_BLOCK

B.EXECUTABLE

C.JAVA_STORED_PROCEDURE

D.STORED_PROCEDURE

E.EXTERNAL

14.Which of the following is not a valid setting for the PROGRAM_TYPE parameter in a program object or the JOB_TYPE parameter in a job object?

A.PLSQL_BLOCK

B.JAVA_STORED_PROCEDURE

C.STORED_PROCEDURE

D.EXECUTABLE

E.None of the above are invalid settings.

Review Questions 

613

15.Which of the following Scheduler elements encourage object reuse? (Choose all that apply.)

A.Schedule objects

B.Program arguments

C.Job classes

D.Job arguments

E.All of the above

16.What is the danger associated with stopping a running job by using the STOP_JOB procedure?

A.The job will need to be reenabled before it will execute again.

B.The job may hold locks on objects referenced within it.

C.All jobs within the job group will also be stopped.

D.The job may leave data in an inconsistent state.

E.There is no danger in using the STOP_JOB procedure.

17.If a job references a schedule that has been disabled, what will be the result?

A.The job will be automatically disabled.

B.The job will never execute.

C.The job will attempt to execute but will fail.

D.The job will inherit the DEFAULT_SCHEDULE schedule.

E.A schedule object cannot be disabled.

18.When a job exceeds the date specified in its END_DATE attribute, which of the following will happen? (Choose all that apply.)

A.The job will be dropped automatically if the value of the AUTO_DROP attribute is TRUE.

B.The job will only be disabled if the value of the AUTO_DROP attribute is FALSE.

C.The STATE attribute of the job will be set to COMPLETED if the value of the AUTO_DROP attribute is FALSE.

D.All objects referenced by the job will be dropped if the value of the AUTO_DROP attribute is TRUE and the value of the CASCADE attribute is TRUE.

E.The STATE column of the job table will be set to COMPLETED for the job.

19.Which of the following is true about job chains?

A.They consist of one or more Scheduler programs.

B.They are used to implement dependency scheduling.

C.They are used to implement time-based scheduling.

D.They are used to implement event-based scheduling.

E.None of the above.

614  Chapter 12  n  Using the Scheduler to Automate Tasks

20.If two windows overlap, which window attribute will determine whether one should be chosen over the other?

A.WINDOW_PRIORITY

B.PRIORITY

C.PRIORITY_LEVEL

D.WINDOW_PRIORITY_LEVEL

E.OVERLAP_RULE

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]