Simple instance of job in Oracle __oracle

Source: Internet
Author: User

Oracle job is simply a function that Oracle provides to execute a stored procedure or package on a regular basis.

The main use scenario
Regularly in the background to perform related operations: such as 0 o'clock every night to save a table of data to another table, 2: Scheduled backup database, etc.

One: Create a test table

Sql> CREATE TABLE TEST (a date);


  
Table has been created.
Two: Create a custom process

sql> Create or replace procedure MYPROC as
2 begin
3 INSERT INTO TEST values (sysdate);
4 End;
5/
process has been created.  


  

Three: Create a job

sql> variable job1 number;
sql> 
sql> begin
2 dbms_job.submit (: Job1, ' MYPROC; ', sysdate, ' sysdate+1/1440 ');   --1440 minutes a day, that is, a minute to run the test process once
3 end;
4/
Pl/sql process has been successfully completed.  


Four: Run job

Sql> begin
2 Dbms_job.run (: JOB1);
3 END;
4/
Pl/sql process has been successfully completed.  



Five: Query Job

Sql> Select To_char (A, ' yyyy/mm/dd hh24:mi:ss ') time from TEST;
Time
-------------------
2001/01/07 23:51:21
2001/01/07 23:52:22
2001/01/07 23:53:24  


VI: Delete Job

Sql> begin
2 dbms_job.remove (: JOB1);
3 END;
The 4/bitscn_com
pl/sql process has completed successfully.  


 

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.