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
- 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>
- SQL>Begin
- 2 dbms_job.submit (: job1, 'myproc; ', sysdate, 'sysdate + 100'); -- 1/1440 minutes a day, that is, one minute to run the test process
- 3 end;
- 4/
- The PL/SQL process is successfully completed.
4. Run the JOB
- SQL>Begin
- 2 dbms_job.run (: job1 );
- 3 end;
- 4/
- The PL/SQL process is successfully completed.
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
- The PL/SQL process is successfully completed.
For more information about Oracle, see Oracle topics page http://www.bkjia.com/topicnews.aspx? Tid = 12