Oracle executes a scheduled task on a daily basis.

Source: Internet
Author: User


Oracle executes a scheduled task every day to create a test table SQL> create table a (a date); www.2cto.com has been created. Create a custom process SQL> create or replace procedure test as 2 begin 3 insert into a values (sysdate); 4 end; 5/the process has been created. Create job SQL> variable job1 number; SQL> begin 2 dbms_job.submit (: job1, 'test; ', 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. Run job SQL> begin 2 dbms_job.run (: job1); 3 end; 4/PL/SQL. Www.2cto.com SQL> select to_char (a, 'yyyy/mm/dd hh24: mi: ss') time from; time ------------------- 2001/01/07 23:51:21 2001/01/07 23:52:22 2001/01/07 23:53:24 Delete job SQL> begin 2 dbms_job.remove (: job1); 3 end; 4/PL/SQL process completed successfully. Select job, to_char (next_date, 'yyyy-mm-dd hh24: mi: ss') from all_jobs; www.2cto.com ---------- use of job: DBMS_JOB.SUBMIT (: jobno, // job no. 'Your _ procedure; ', // the process to be executed, trunc (sysdate) + 1/24, // The next execution time, 'trunc (sysdate) + 1/24 + 1' // interval); Delete job: dbms_job.remove (jobno); Modify the operation to be executed: job: dbms_job.what (jobno, what); Modify the next execution time: dbms_job.next_date (job, next_date); modification interval: dbms_job.interval (job, interval); stop job: dbms. broken (job, broken, nextdate); start job: dbms_job.run (jobno); example: VARIABLE jobno number; begin DBMS_JOB.SUBMIT (: jobno, 'procdemo ;', // Procdemo is the process name SYSDATE, 'sysdate + 1/720 '); commit; end; www.2cto.com ----- modify the value of job_queue_processes (ensure that it is not 0 or the JOB is not run automatically) you can use select * from v $ parameter; to view its value. Method 1: startup pfile = 'C:/oracle/ora90/database/initorcl. ora '; you need to modify initorcl. the job_queue_processes parameter in the ora file. method 2 will take effect after the database is restarted. alter system set job_queue_processes = 10. The system automatically modifies init. ora file www.2cto.com 1), execute Interval => TRUNC (sysdate, 'mi') + 1/(24*60) 2) every minute, and regularly execute every day for example: execute Interval => TRUNC (sysdate) + 1 + 2/(24) 3) at every day, and execute regularly every week for example: execute Interval => TRUNC (next_day (sysdate, 2) + 2/24 every Monday, the second day of the week 4), scheduled monthly execution for example: execute Interval => TRUNC (LAST_DAY (SYSDATE) + 1 + 2/24 5 at on the first day of each month) perform scheduled execution on a quarterly basis. For example, execute Interval => TRUNC (ADD_MONTHS (SYSDATE, 3), 'q') + 2/24 6 at on the first day of each quarter) scheduled execution every six months, for example, at Interval => ADD_MONTHS (trunc (sysdate, 'yyyy'), 6) + 2/24 7), and annual scheduled execution for example: execute Interval => ADD_MONTHS (trunc (sysdate, 'yyyy'), 12) + 2/24 at every year.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.