What is the relationship between the Last_date and next_date in the job, and the interval, last_date the start of the job, or the end of the execution time. Next_date is the job start time or end time plus interval.
If a job has a long execution time (such as interval), there will be multiple identical jobs executing concurrently.
last_date= Start time
Last_date+interval=next_date
But to be clear, next_date is usually not the real start time, the real start time is often a few seconds later than Next_date,
Which is the delay.
2, not.
1
The job's next time is even better when the job starts executing.
It's written only after the job is executed successfully.
When the job execution time is longer than interval, which means that during the execution of the job, Nexttime is over.
Then nexttime becomes the time when the job is done
2
What you're saying doesn't exist.
sql> exec Dbms_job.broken (21,true);
The Pl/sql process was successfully completed
Sql> select * from User_jobs;
JOB log_user priv_user Schema_ user last_date last_sec THIS_DATE this_sec next_date NEXT_SEC Total_time Broken interval Failures what nls_env misc_env INSTANCE
---------- ------------------------------ ------------------------------ ------------------------------ ----------- ---------------- ----------- ---------------- ----------- ---------------- ---------- ------ ------------------------- ------------------------------------------------------- ---------- ---------------------------------------------- ---------------------------------- ----------------------------------------------------------------------------- --- ---------------------------------------------------------------- ----------
unions unions unions 2006-11-30 16:32:27 4000-1-1 00:00:00 0 y trunc (sysdate) +16/24+1 0 achievetohistory; nls_language= ' Simplified Chinese ' nls_territory= ' nls_currency= ' RMB ' nls_i 0
sql> exec Dbms_job.run (21);
The Pl/sql process was successfully completed
Sql> select * from User_jobs;
JOB log_user priv_user Schema_ user last_date last_sec THIS_DATE this_sec next_date NEXT_SEC Total_time Broken interval Failures what nls_env misc_env INSTANCE
---------- ------------------------------ ------------------------------ ------------------------------ ----------- ---------------- ----------- ---------------- ----------- ---------------- ---------- ------ ------------------------- ------------------------------------------------------- ---------- ---------------------------------------------- ---------------------------------- ----------------------------------------------------------------------------- --- ---------------------------------------------------------------- ----------
unions unions unions 2006-11-30 16:46:14 2006-12-1 1 16:00:00 0 n trunc (sysdate) +16/24+1 0 achievetohistory; nls_language= ' Simplified Chinese ' nls_territory= ' nls_currency= ' ' RMB ' nls_i 0102000200000000 0
Try to write a scheduled task:
Declare
V_job number: = 1;
Begin
Dbms_job.submit (V_job, ' sp_fact_charge_code; ', sysdate, ' sysdate+1/1440 ');
Commit
End
/
Explain the procedure above.
The program body has four parameters, respectively, meaning: V_job is the plan task number, ' Sp_fact_charge_ Code ' is the scheduled task name, if it is more than one scheduled task, separated by semicolons, the third sysdate means to perform this task immediately, the fourth parameter is the interval time setting, which is executed once per minute, 1/1440=1/24/60.
View tasks: SELECT * from User_jobs;select * all_jobs;
View running tasks (deprecated, slow): SELECT * from dba_jobs_running;
It is also worth mentioning that when installing Oracle configuration, there is a parameter:
Job_queue_processes=4 (default 4)
This parameter defines the maximum number of jobs that can be run at the current time, and its max value can be set to 36.
In addition to the submit parameters, some of the remaining parameters are:
Dbms_job.run (V_job); Run Job
Dbms_job.broken (v_job,true,next_date); Stop a job, the inside parameter true also but False,next_date (stop at a moment) also is sysdate (stop immediately).
Dbms_job.remove (V_job); Delete a job
Dbms_job.what (V_job, ' sp_fact_charge_code; '); Modify a job name
Dbms_job.next_date (v_job,sysdate); Modify Next Run time
example, set to run 2:10:10 every day
Trunc (sysdate) +2/24+10/24/60+10/24/60/60//Run time
Trunc (sysdate) +1+2/24+10/24/60+10/24/60/60//Interval run time
example, set the 2:10:10 operation of number 2nd per month
Trunc (sysdate, ' mm ') +1+2/24+10/24/60+10/24/60/60//Run time
Trunc (Add_mouths (sysdate,1), ' mm ') +1+2/24+10/24/60+10/24/60/60//Interval run time
example, set each quarter ...
Trunce (sysdate, ' Q ') +1+2/24+10/24/60+10/24/60/60//Run time
Trunce (Add_mouths (sysdate,3), ' Q ') +1+2/24+10/24/60+10/24/60/60//Interval run time
The other year is ' Y;
example, set weekly one ...
Next_day (sysdate ' Monday ')
......