1), execute by minute
Execute every minute
TRUNC(SYSDATE,'mi') + 1/(24*60)
Every five minutes
TRUNC(SYSDATE,'mi') + 5/(24*60)
2). Execute by hour
Every hour
TRUNC(SYSDATE,'mi') + 1/24
Execute every five hours
TRUNC(SYSDATE,'mi') + 5/24
3), execute by day
Every day at 2 am
TRUNC(SYSDATE) + 1 +2/(24)
For example: execute every 5 days at 2 am
TRUNC(SYSDATE) + 5 +2/(24)
4). Weekly execution
Run every Monday at 2am
TRUNC (NEXT_DAY (SYSDATE, 2)) +2/24-Monday (the second day of the week)
Every Saturday at 2am
TRUNC (NEXT_DAY (SYSDATE, 7)) + 2/24-Saturday (the seventh day of the week)
5), executed monthly
Executed at 2am on the 1st of every month
TRUNC(LAST_DAY(SYSDATE))+1+2/24
Execute at 10 am on the 5th of each month
TRUNC(LAST_DAY(SYSDATE))+5+10/24
6), quarterly execution
Execute at 2am on the first day of each quarter
TRUNC(ADD_MONTHS(SYSDATE,3),'Q') + 2/24
7), execute regularly every six months
Every year on July 1st and January 1st at 2 am
ADD_MONTHS(TRUNC(SYSDATE,'yyyy'),6)+2/24
--select TRUNC(SYSDATE,'yyyy') from dual;
--select ADD_MONTHS(TRUNC(SYSDATE,'yyyy'),6) from dual;
8), execute regularly every year
Every year on January 1st at 2 am
ADD_MONTHS(TRUNC(SYSDATE,'yyyy'),12)+2/24
supplement:
1、
NEXT_DAY(d,number)
--Start at time d, the date of the next day of the week
--Sunday: 1, Monday: 2, Tuesday: 3, Wednesday: 4, Thursday: 5, Friday: 6, Saturday: 7
2、
ADD_MONTHS(d,n)
--Return to time point d plus n months
3、
LAST_DAY(d)
--Time point d the last day of the month
4、
TRUNC(d[,fmt])
-Intercept the date
--For example, the current time is: 2012-08-06 04:39:00
SELECT TRUNC(SYSDATE,'mm') FROM dual
--Return to the first day of the month of August 2012
SELECT TRUNC(SYSDATE,'yy') FROM dual
--Return to the first day of 2012-1-1
SELECT TRUNC(SYSDATE,'dd') FROM dual
--Return to the day of August 8, 2012
SELECT TRUNC(SYSDATE,'day') FROM dual
--Return to the first day of the week of 2012-8-5
SELECT TRUNC(SYSDATE) FROM dual
--Return to 2012-8-6 without filling in the parameters, the default is the day
SELECT TRUNC(SYSDATE,'hh') FROM dual
--Return to the current hour of 2012-8-6 at 04:00:00 PM
SELECT TRUNC(SYSDATE,'mi') FROM dual
--Return to the current minute at 4:39:00 on August 8, 2012