What is the relationship between last_date and next_date in the job and interval? Does last_date indicate the start time and end time of the job. Is next_date the start time of the job or the end time plus interval?
If a job is executed for a long time (for example, beyond interval), will multiple identical jobs be executed simultaneously?
Last_date = Start Time
Last_date + interval = next_date
But it should be clear that next_date is generally not the actual start time, and the actual start time is usually several seconds later than next_date,
That is, latency.
2. No.
1
The next time of the job is fine when the job starts to run.
It is written only after the job is successfully executed.
When the job execution time is longer than interval, that is to say, the nexttime has passed in the job execution process.
The nexttime is the time when the job is executed.
2
The situation you mentioned does not exist.
SQL> exec dbms_job.broken (21, true );
The PL/SQL process is 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
---------- Begin certificate ------------------------------ ------------- ---------------- -------------------- ------------- ---------------- ---------- begin -------- begin certificate -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
21 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 = 'China' nls_currency =' RMB 'nls_ I 0102000200000000 0
SQL> exec dbms_job.run (21 );
The PL/SQL process is 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
---------- Begin certificate ------------------------------ ------------- ---------------- -------------------- ------------- ---------------- ---------- begin -------- begin certificate -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
21 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 = 'China' nls_currency =' RMB 'nls_ I 0102000200000000 0
Test A scheduled task:
Declare
V_job number: = 1;
Begin
Dbms_job.submit (v_job, 'SP _ fact_charge_code; ', sysdate, 'sysdate + 100 ');
Commit;
End;
/
Explain the above program
The main program has four parameters: v_job is the scheduled task number, and 'SP _ fact_charge_code 'is the name of the scheduled task. If multiple scheduled tasks exist, they are separated by semicolons, the third sysdate indicates that the task is executed immediately. The fourth parameter is the interval setting, where the task is executed once every minute, 1/1440 = 1/24/60.
View the task: Select * From user_jobs; select * From all_jobs;
View running tasks (not recommended, slow speed): Select * From dba_jobs_running;
It is also worth mentioning that when installing the Oracle configuration, there is such a parameter:
Job_queue_processes = 4 (default value: 4)
This parameter defines that a maximum of several jobs can be run at the moment, and its maximum value can be set to 36.
In addition to the submit parameter, the following parameters are available:
Dbms_job.run (v_job); // run the job
Dbms_job.broken (v_job, true, next_date); // stop a job. The true parameter in the job is also false, and next_date (stops at a certain time) is sysdate (stops immediately ).
Dbms_job.remove (v_job); // deletes a job.
Dbms_job.what (v_job, 'SP _ fact_charge_code; '); // modify a job name
Dbms_job.next_date (v_job, sysdate); modifies the next running time
Example: set to run at 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 // Run Time Interval
Example: set to run at 2:10:10 on the second day of every 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 // run Interval
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 // run Interval
The other year is 'y;
Example: set every Monday ......
Next_day (sysdate 'monday ')
......