Oracle Scheduler: Calendaring

Oracle Scheduler: Calendaring Syntax

|-----------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| freq=daily | Run once per day |
| freq=daily;bymonthday=2 | Run once on each 2nd day of a month |
| freq=daily;bymonthday=-1 | Run on the last day of a month |
| freq=daily;byday=tue | Run on Tuesdays. For a strange reason, the given value freq= is irrelevant: freq=monthly;byday=tue or freq=minutely;byday=tue etc. produce the same calendar! |
| freq=daily;byday=tue; byhour=12; byminute=0; bysecond=0 | Run on tuesdays almost exactly at noon (the fraction of a second cannot be specified). |
| freq=monthly;byday=2tue | Run on each month's second tuesday |
| freq=minutely;interval=5 | Run every fifth minute. |
| freq=hourly;byminute=7,31,42 | Runs three times per hour: on each hour's 7th, 31st and 42nd minute. |
| freq=minutely;byhour=7,8,16,17 | Runs every minute, but only between 7:00 and 9:00, and between 16:00 and 18:00. |
| freq=monthly;byday=mon,tue,wed,thu,fri;bysetpos=1 | Runs on each month's first business day. |
| freq=monthly;byday=mon,tue,wed,thu,fri;bysetpos=-1 | Runs on each month's last business day. |
| freq=daily;byday=mon,tue,wed,thu,fri;exclude=holidays | Run daily, Monday through Friday, but exclude days referenced in the schedule named holidays. |

Testing calendar strings

The following procedure can be used to test a calendar string

复制代码
create or replace procedure tq84_test_calendaring_syntax (
   calendar_string varchar2,
   start_date      timestamp with time zone := systimestamp,
   n               integer                  := 10
)
   authid definer
as
   next_run_date   timestamp with time zone := start_date;
begin

   for i in 1 .. n loop

      dbms_scheduler.evaluate_calendar_string(
         calendar_string   => calendar_string,
         start_date        => start_date,
         return_date_after => next_run_date,
         next_run_date     => next_run_date
     );

     dbms_output.put_line(next_run_date);

   end loop; 
end tq84_test_calendaring_syntax;
/

Time zone

The value of the scheduler's default time zone is important when using the calendaring syntax. This value can be queried like so:

复制代码
select
   value
from
   dba_scheduler_global_attribute
where
   attribute_name = 'DEFALT_TIMEZONE'
;

The value can be set with dbms_scheduler.set_scheduler_attribute.

相关推荐
赵渝强老师1 小时前
【赵渝强老师】国产金仓数据库的数据库对象
数据库·postgresql·oracle·oceanbase·国产数据库
oioihoii3 小时前
Oracle迁移KingbaseES实战
数据库·oracle
zAnllYrAbIo3 小时前
探索基于QCustomPlot的强大数据可视化工具
oracle
赵渝强老师3 小时前
【赵渝强老师】Oracle多租户容器数据库
数据库·oracle
hunter14504 小时前
2026.1.20 sql server简单操作
数据库·oracle
达梦产品与服务4 小时前
SQLark 实战 | 如何快速导入数据至达梦、Oracle、MySQL、PG 数据库
mysql·oracle·达梦数据库·数据导入·pg数据库
小天源8 小时前
Oracle Database 11g Express Edition (XE) 11.2.0.2 在离线银河麒麟 V10 上的部署手册
数据库·oracle·express·麒麟v10·oracle11g·oracle-xe-11g
全栈小59 小时前
【数据库】Oracle数据库迁移的深层痛点:兼容性、成本与隐性挑战
数据库·oracle
人道领域10 小时前
javaWeb从入门到进阶(MYSQL)
数据库·mysql·oracle
知识分享小能手10 小时前
Oracle 19c入门学习教程,从入门到精通,Oracle 数据表对象 —— 语法知识点详解与案例实践(10)
数据库·学习·oracle