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.