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.