Why use the job:
A job allows a user to schedule and schedule a task in advance, allowing it to be automatically executed one or more times during a specified time or time period, and is highly efficient because the task is executed in the database.
Job allows us to customize the execution time of the task and provide flexible processing, but also through configuration, scheduling tasks in the system user access to a small number of times to execute, greatly improve the efficiency.
For example, time-consuming, repetitive work for database daily backups, updates, deletions, and replications.
The other is not to say, directly cut to the chase
---------------------------------Test
--Create a test table
CREATE TABLE T_job (d Date);
SELECT * from T_job;
--The stored procedure executed by the job
CREATE OR REPLACE PROCEDURE pro_job
Is
BEGIN
INSERT into T_job Values (sysdate);
End;
--The job that is scheduled to execute
---Executing in a command window
VARIABLE into_job number;
BEGIN
Dbms_job.submit (
: Into_job,--
' Pro_job; ',
Sysdate,
' sysdate+1/1440 '
);
End;
--so the job is created, and the job is done.
--Executing in command window
Execute Dbms_job.run (job number); Commit
Where the job number is automatically generated by Oracle, it is generated when the job is created.
--Delete Job
Execute Dbms_job.remove (job number); Commit