Database Administration · Unit 9
Job Scheduling and Automation
Exam-focused notes for Job Scheduling and Automation (Database Administration, BIT352): what the TU syllabus asks and how it has actually been tested, with 4 solved past questions from this unit.
Job Scheduling and Automation in short
Many DBA tasks repeat: backups, statistics, cleaning old data and reports. The Oracle Scheduler runs them automatically, so the DBA does not have to start each one by hand.
What this unit covers
- Job scheduling in oracle database
- DBMS_SCHEDULER functionality
- Scheduler components
- Schedule definition and creation
- Job and job classes
- Program definition and relationship
- Event-based schedule creation
- Schedule, job and program relationships
Event-based schedule creation
Job scheduling in oracle database
2080 · 5 marks
What is Job Scheduling in oracle database? How DBMS_ SCHEDULER Works? Explain the different component of scheduler. [5]
Job and job classes
2081.1 · 5 marks
What is Job and Job classes? Create an event-based schedule in Oracle. [5]
Show solved answerHide answer
Jobs and Job Classes in Oracle Scheduler
What is a Job?
A Job is a scheduled task or unit of work that Oracle Scheduler executes at a specified time or interval. A job defines:
- What to run (a PL/SQL block, stored procedure, or executable)
- When to run (a schedule or specific time)
- How to run (priority, logging level, etc.)
What is a Job Class?
A Job Class is a logical grouping of jobs that share common attributes such as:
- Resource consumer group (for resource management)
- Service name (which database service to use)
- Logging level (how much logging to perform)
- Priority among jobs within the same window
Job classes allow DBAs to manage and prioritize groups of jobs collectively rather than individually.
Creating an Event-Based Schedule in Oracle
An event-based schedule triggers a job when a specific event occurs (e.g., a message is enqueued into an Oracle Advanced Queue), rather than at a fixed time.
Step 1: Create an Event Queue (Advanced Queue)
-- Create a queue table
BEGIN
DBMS_AQADM.CREATE_QUEUE_TABLE(
queue_table => 'event_queue_table',
queue_payload_type => 'SYS.SCHEDULER$_EVENT_INFO'
);
END;
/
-- Create the queue
BEGIN
DBMS_AQADM.CREATE_QUEUE(
queue_name => 'my_event_queue',
queue_table => 'event_queue_table'
);
END;
/
-- Start the queue
BEGIN
DBMS_AQADM.START_QUEUE(queue_name => 'my_event_queue');
END;
/
Step 2: Create the Event-Based Schedule
BEGIN
DBMS_SCHEDULER.CREATE_SCHEDULE(
schedule_name => 'my_event_schedule',
event_condition => 'tab.user_data.event_type = ''MY_EVENT''',
queue_spec => 'my_event_queue'
);
END;
/
Step 3: Create a Job Using the Event-Based Schedule
BEGIN
DBMS_SCHEDULER.CREATE_JOB(
job_name => 'my_event_job',
job_type => 'STORED_PROCEDURE',
job_action => 'my_procedure',
schedule_name => 'my_event_schedule',
enabled => TRUE,
comments => 'Job triggered by an event'
);
END;
/
Step 4: Create a Job Class (Optional but Recommended)
BEGIN
DBMS_SCHEDULER.CREATE_JOB_CLASS(
job_class_name => 'my_job_class',
resource_consumer_group => 'DEFAULT_CONSUMER_GROUP',
logging_level => DBMS_SCHEDULER.LOGGING_FULL,
comments => 'Job class for event-based jobs'
);
END;
/
Summary Table
| Concept | Description |
|---|---|
| Job | A scheduled unit of work (what + when + how) |
| Job Class | A group of jobs sharing common resource/logging attributes |
| Event-Based Schedule | A schedule triggered by an event (queue message) rather than time |
Note: The
DBMS_SCHEDULERpackage is the standard Oracle utility used to create and manage jobs, job classes, and schedules.
Schedule, job and program relationships
0 · 5 marks
Explain relationship between schedule, job and program. Create a Schedule in oracle. [5]
Make Unit 9 stick
Practice BIT352 with flashcards & quizzes