Simple instances of jobs in Oracle

Source: Internet
Author: User

Oracle job is a function provided by Oracle to regularly execute a stored procedure or package.

Main scenarios
Perform related operations on the background at regular intervals. For example, save the data of one table to another at every night, and 2. Back up the database at regular intervals.

I. Create a test table

 
SQL> Create Table Test (a date );


The table has been created.
Ii. Create a custom Process

 
SQL> Create or replace procedure myproc as 2 begin 3 insert into test values (sysdate); 4 end; 5/the process has been created.

3. Create a job

 
SQL> variable job1 number; SQL> begin 2 dbms_job.submit (: job1, 'myproc; ', sysdate, 'sysdate + 100'); -- 1/1440 minutes a day, that is, the test process is run at a time of 3 end; 4/PL/SQL process has been completed successfully.

 

4. Run the job

 
SQL> begin 2 dbms_job.run (: job1); 3 end; 4/PL/SQL process completed successfully.

V. query a 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 a job

 
SQL> begin 2 dbms_job.remove (: job1); 3 end; 4/bitscn_com PL/SQL process completed successfully.

 

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.