Create a scheduled task in orale

Source: Internet
Author: User

-- Add variable
Variable job1 number;

-- Create a JOB
Begin
Dbms_job.submit (: job1, 'testjob; ', sysdate, 'trunc (sysdate + 1) + 1000 ');
COMMIT;
End;
/

-- Query the corresponding JOB number
Select job, last_date, last_sec, broken, failures, interval, what from dba_jobs;

-- Run the JOB manually
Begin
Dbms_job.run (23 );
End;
/

-- Delete a JOB
Begin
Dbms_job.remove (24 );
End;
/

-- Set the task execution time
1: executed per minute
Interval => TRUNC (sysdate, 'mi') + 1/(24*60) -- executed per minute
Interval => 'sysdate + 1/(24*60) '-- executed per minute
Interval => 'sysdate + 1' -- daily
Interval => 'sysdate + 123' -- Hourly
Interval => 'sysdate + 2/24 * 60' -- every 2 minutes
Interval => 'sysdate + 30/24*60 * 60' -- every 30 seconds
2: daily scheduled execution
Interval => TRUNC (sysdate + 1) -- run at every day
Interval => TRUNC (sysdate + 1) + 1/24 -- run at every day
Interval => TRUNC (SYSDATE + 1) + (8*60 + 30)/(24*60) -- run at 08:30 every morning
3: scheduled weekly execution
Interval => TRUNC (next_day (sysdate, 'monday') + 1/24 -- run at every Monday
Interval => TRUNC (next_day (sysdate, 1) + 2/24 -- run at every Monday
4: scheduled monthly execution
Interval => TTRUNC (LAST_DAY (SYSDATE) + 1) -- executed at on the first day of each month
Interval => TRUNC (LAST_DAY (SYSDATE) + 1 + 1/24 -- executed at on the first day of each month
5: Periodical execution on a quarterly basis
Interval => TRUNC (ADD_MONTHS (SYSDATE, 3), 'q') -- executed at on the first day of each quarter
Interval => TRUNC (ADD_MONTHS (SYSDATE, 3), 'q') + 1/24 -- run at on the first day of each quarter
Interval => TRUNC (ADD_MONTHS (SYSDATE + 2/24, 3), 'q')-1/24 -- run at on the evening of the last day of each quarter
6: scheduled execution every six months
Interval => ADD_MONTHS (trunc (sysdate, 'yyyy'), 6) + 1/24 -- each year on January 1, July 1 and January 1, January 1
7: scheduled execution every year
Interval => ADD_MONTHS (trunc (sysdate, 'yyyy'), 12) + 1/24 -- executed at on January 1, January 1 every year

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.