Brief introduction to Oracle based jobs

Source: Internet
Author: User

Why use the job:
A job allows a user to schedule and schedule a task in advance, allowing it to be automatically executed one or more times during a specified time or time period, and is highly efficient because the task is executed in the database.
Job allows us to customize the execution time of the task and provide flexible processing, but also through configuration, scheduling tasks in the system user access to a small number of times to execute, greatly improve the efficiency.
For example, time-consuming, repetitive work for database daily backups, updates, deletions, and replications.

The other is not to say, directly cut to the chase

---------------------------------Test

--Create a test table
CREATE TABLE T_job (d Date);
SELECT * from T_job;

--The stored procedure executed by the job

CREATE OR REPLACE PROCEDURE pro_job
Is
BEGIN
INSERT into T_job Values (sysdate);
End;

--The job that is scheduled to execute

---Executing in a command window
VARIABLE into_job number;
BEGIN
Dbms_job.submit (
: Into_job,--
' Pro_job; ',
Sysdate,
' sysdate+1/1440 '
);
End;

--so the job is created, and the job is done.

--Executing in command window
Execute Dbms_job.run (job number); Commit

Where the job number is automatically generated by Oracle, it is generated when the job is created.

--Delete Job

Execute Dbms_job.remove (job number); Commit

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.