返回顶部
首页 > 资讯 > 数据库 >dbms_scheduler create_job repeat_interval 列子
  • 427
分享到

dbms_scheduler create_job repeat_interval 列子

2024-04-02 19:04:59 427人浏览 八月长安
摘要

文章 from oracle 官网29.4.5 Setting the Repeat IntervalYou can control when and how often a job repeat

文章 from oracle 官网

29.4.5 Setting the Repeat Interval

You can control when and how often a job repeats.

29.4.5.1 About Setting the Repeat Interval

You control when and how often a job repeats by setting the repeat_interval attribute of the job itself or the named schedule that the job references. You can set repeat_interval with DBMS_SCHEDULER package procedures or with Cloud Control.

Evaluating the repeat_interval results in a set of timestamps. The Scheduler runs the job at each timestamp. Note that the start date from the job or schedule also helps determine the resulting set of timestamps. If no value for repeat_interval is specified, the job runs only once at the specified start date.

Immediately after a job starts, the repeat_interval is evaluated to determine the next scheduled execution time of the job. While this might arrive while the job is still running, a new instance of the job does not start until the current one completes.

See Also:

Oracle Database PL/SQL Packages and Types Reference for more infORMation about repeat_interval evaluation

29.4.5.2 Using the Scheduler Calendaring Syntax

The main way to set how often a job repeats is to set the repeat_interval attribute with a Scheduler calendaring expression.

See Also:

Oracle Database PL/SQL Packages and Types Reference for a detailed description of the calendaring syntax for repeat_interval as well as the CREATE_SCHEDULE procedure

Examples of Calendaring Expressions

The following examples illustrate simple repeat intervals. For simplicity, it is assumed that there is no contribution to the evaluation results by the start date.

Run every Friday. (All three examples are equivalent.)

FREQ=DAILY; BYDAY=FRI;
FREQ=WEEKLY; BYDAY=FRI;
FREQ=YEARLY; BYDAY=FRI;

Run every other Friday.

FREQ=WEEKLY; INTERVAL=2; BYDAY=FRI;

Run on the last day of every month.

FREQ=MONTHLY; BYMONTHDAY=-1;

Run on the next to last day of every month.

FREQ=MONTHLY; BYMONTHDAY=-2;

Run on March 10th. (Both examples are equivalent)

FREQ=YEARLY; BYMONTH=MAR; BYMONTHDAY=10;
FREQ=YEARLY; BYDATE=0310;

Run every 10 days.

FREQ=DAILY; INTERVAL=10;

Run daily at 4, 5, and 6PM.

FREQ=DAILY; BYHOUR=16,17,18;

Run on the 15th day of every other month.

FREQ=MONTHLY; INTERVAL=2; BYMONTHDAY=15;

Run on the 29th day of every month.

FREQ=MONTHLY; BYMONTHDAY=29;

Run on the second Wednesday of each month.

FREQ=MONTHLY; BYDAY=2WED;

Run on the last Friday of the year.

FREQ=YEARLY; BYDAY=-1FRI;

Run every 50 hours.

FREQ=HOURLY; INTERVAL=50;

Run on the last day of every other month.

FREQ=MONTHLY; INTERVAL=2; BYMONTHDAY=-1;

Run hourly for the first three days of every month.

FREQ=HOURLY; BYMONTHDAY=1,2,3;

Here are some more complex repeat intervals:

Run on the last workday of every month (assuming that workdays are Monday through Friday).

FREQ=MONTHLY; BYDAY=MON,TUE,WED,THU,FRI; BYSETPOS=-1

Run on the last workday of every month, excluding company holidays. (This example references an existing named schedule called Company_Holidays.)

FREQ=MONTHLY; BYDAY=MON,TUE,WED,THU,FRI; EXCLUDE=Company_Holidays; BYSETPOS=-1

Run at noon every Friday and on company holidays.

FREQ=YEARLY;BYDAY=FRI;BYHOUR=12;INCLUDE=Company_Holidays

Run on these three holidays: July 4th, Memorial Day, and Labor Day. (This example references three existing named schedules, JUL4MEM, and LAB, where each defines a single date corresponding to a holiday.)

JUL4,MEM,LAB

Examples of Calendaring Expression Evaluation

A repeat interval of "FREQ=MINUTELY;INTERVAL=2;BYHOUR=17; BYMINUTE=2,4,5,50,51,7;" with a start date of 28-FEB-2004 23:00:00 will generate the following schedule:

SUN 29-FEB-2004 17:02:00
SUN 29-FEB-2004 17:04:00
SUN 29-FEB-2004 17:50:00
MON 01-MAR-2004 17:02:00
MON 01-MAR-2004 17:04:00
MON 01-MAR-2004 17:50:00
...

A repeat interval of "FREQ=MONTHLY;BYMONTHDAY=15,-1" with a start date of 29-DEC-2003 9:00:00 will generate the following schedule:

WED 31-DEC-2003 09:00:00
THU 15-JAN-2004 09:00:00
SAT 31-JAN-2004 09:00:00
SUN 15-FEB-2004 09:00:00
SUN 29-FEB-2004 09:00:00
MON 15-MAR-2004 09:00:00
WED 31-MAR-2004 09:00:00
...

A repeat interval of "FREQ=MONTHLY;" with a start date of 29-DEC-2003 9:00:00 will generate the following schedule. (Note that because there is no BYMONTHDAY clause, the day of month is retrieved from the start date.)

MON 29-DEC-2003 09:00:00
THU 29-JAN-2004 09:00:00
SUN 29-FEB-2004 09:00:00
MON 29-MAR-2004 09:00:00
...

Example of Using a Calendaring Expression

As an example of using the calendaring syntax, consider the following statement:

BEGIN
  DBMS_SCHEDULER.CREATE_JOB (
   job_name             => 'scott.my_job1',
   start_date           => '15-JUL-04 01.00.00 AM Europe/Warsaw',
   repeat_interval      => 'FREQ=MINUTELY; INTERVAL=30;',
   end_date             => '15-SEP-04 01.00.00 AM Europe/Warsaw',
   comments             => 'My comments here');
END;
/

This creates my_job1 in scott. It will run for the first time on July 15th and then run until September 15. The job is run every 30 minutes.

29.4.5.3 Using a PL/SQL Expression

When you need more complicated capabilities than the calendaring syntax provides, you can use PL/SQL expressions. You cannot, however, use PL/SQL expressions for windows or in named schedules. The PL/SQL expression must evaluate to a date or a timestamp.

Other than this restriction, there are no limitations, so with sufficient programming, you can create every possible repeat interval. As an example, consider the following statement:

BEGIN
  DBMS_SCHEDULER.CREATE_JOB (
   job_name             => 'scott.my_job2', 
   start_date           => '15-JUL-04 01.00.00 AM Europe/Warsaw',
   repeat_interval      => 'SYSTIMESTAMP + INTERVAL '30' MINUTE',
   end_date             => '15-SEP-04 01.00.00 AM Europe/Warsaw',
   comments             => 'My comments here');
END;
/

This creates my_job1 in scott. It will run for the first time on July 15th and then every 30 minutes until September 15. The job is run every 30 minutes because repeat_interval is set to SYSTIMESTAMP + INTERVAL '30' MINUTE, which returns a date 30 minutes into the future.

29.4.5.4 Differences Between PL/SQL Expression and Calendaring Syntax Behavior

There are important differences in behavior between a calendaring expression and PL/SQL repeat interval.

These differences include the following:

  • Start date

    • Using the calendaring syntax, the start date is a reference date only. Therefore, the schedule is valid as of this date. It does not mean that the job will start on the start date.

    • Using a PL/SQL expression, the start date represents the actual time that the job will start executing for the first time.

  • Next run time

    As an example of the difference, for a job that is scheduled to start at 2:00 PM and repeat every 2 hours, but actually starts at 2:10:

    • If calendaring syntax specified the repeat interval, then it would repeat at 4, 6 and so on.

    • If a PL/SQL expression is used, then the job would repeat at 4:10, and if the next job actually started at 4:11, then the subsequent run would be at 6:11.

    • Using the calendaring syntax, the next time the job runs is fixed.

    • Using the PL/SQL expression, the next time the job runs depends on the actual start time of the current job run.

To illustrate these two points, consider a situation where you have a start date of 15-July-2003 1:45:00 and you want it to repeat every two hours. A calendar expression of "FREQ=HOURLY; INTERVAL=2; BYMINUTE=0;" will generate the following schedule:

TUE 15-JUL-2003  03:00:00
TUE 15-JUL-2003  05:00:00
TUE 15-JUL-2003  07:00:00
TUE 15-JUL-2003  09:00:00
TUE 15-JUL-2003  11:00:00
...

Note that the calendar expression repeats every two hours on the hour.

A PL/SQL expression of "SYSTIMESTAMP + interval '2' hour", however, might have a run time of the following:

TUE 15-JUL-2003  01:45:00
TUE 15-JUL-2003  03:45:05
TUE 15-JUL-2003  05:45:09
TUE 15-JUL-2003  07:45:14
TUE 15-JUL-2003  09:45:20
...


您可能感兴趣的文档:

--结束END--

本文标题: dbms_scheduler create_job repeat_interval 列子

本文链接: https://lsjlt.com/news/44089.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
  • dbms_scheduler create_job repeat_interval 列子
    文章 from oracle 官网29.4.5 Setting the Repeat IntervalYou can control when and how often a job repeat...
    99+
    2024-04-02
  • Oracle系列:(14)子查询
    子查询的作用:查询条件未知的事物查询条件已知的问题:例如:查询工资为800的员工信息查询条件未知的问题:例如:查询工资为20号部门平均工资的员工信息一个条件未知的问题,可以分解为多个条件已知的问题查询工资比...
    99+
    2024-04-02
  • Oracle系列:(5)select子句
    使用scott用户下emp表进行测试0、环境设置--以下代码是对emp表进行显示做设置 col empno for 9999; col ename for...
    99+
    2024-04-02
  • Oracle系列:(7)order by子句
    查询员工信息(编号,姓名,月薪,年薪),按月薪升序排序,默认升序,如果月薪相同,按oracle内置的校验规则排序select empno,ename,sal,sal*12  f...
    99+
    2024-04-02
  • SqlServer系列笔记——子查询
    子查询意思:将一个查询语句做为一个结果集供其他SQL语句使用,就像使用普通的表一样,被当作结果集的查询语句被称为子查询所有可以使用表的地方几乎都可以使用子查询来代替。关键子 IN exists N...
    99+
    2024-04-02
  • python如何获取子列表
    小编给大家分享一下python如何获取子列表,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!获取子列表x = [1,2,3,4,5,6]#前3个...
    99+
    2023-06-17
  • 最长公共子序列(LCS)
    【问题】 求两字符序列的最长公共字符子序列 1 def lcs_length(x,y): 2 m = len(x) 3 n = len(y) 4 c = [[0 for _ in range(n+1)...
    99+
    2023-01-31
    序列 最长 LCS
  • C++LeetCode300最长递增子序列
    目录LeetCode 300.最长递增子序列方法一:动态规划AC代码C++LeetCode 300.最长递增子序列 力扣题目链接:leetcode.cn/pro...
    99+
    2022-12-16
    C++ 最长递增子序列 C++ LeetCode递增子序列
  • Mysql---子查询的三种查询方式( 表子查询,条件子查询,列中子查询)
    mysql子查询 子查询分为: 列中子查询 单列单行表子查询 必须有别名条件子查询 单行单列 多行单列 下列示例表结构: grade表: result表: student表: subject表:...
    99+
    2023-09-04
    mysql sql 数据库
  • python算法练习之兔子产子(斐波那切数列)
    目录1.问题描述2.问题分析3.算法设计4.完整程序1.问题描述 有一对兔子,从出生后的第3个月起每个月都生一对兔子。小兔子长到第3个月后每个月又生一对兔子,假设所有的兔子都不死,问...
    99+
    2024-04-02
  • C++判断子序列题目详解
    目录判断子序列一、解题思路1、解法一( Java )总结判断子序列 给定字符串 s 和 t ,判断 s 是否为 t 的子序列。 说明: 1.字符串的一个子序列是原始字符串删除一些(...
    99+
    2024-04-02
  • Oracle怎么截取VARCHAR列的子串
    这篇文章将为大家详细讲解有关Oracle怎么截取VARCHAR列的子串,小编觉得挺实用的,因此分享给大家做个参考,希望大家阅读完这篇文章后可以有所收获。Oracle 中截取 VARCHAR 列子串 简介 截取 VARCHAR 列的子串是一种...
    99+
    2024-05-09
    SUBSTR INSTR 正则表达式 性能 VARCHAR
  • 索引优化系列三 聚合因子
    --colocated表根据x列有一定的物理顺序 drop table colocated purge;create table colocated ( x int, y varcha&...
    99+
    2024-04-02
  • C++实现LeetCode(115.不同的子序列)
    [LeetCode] 115. Distinct Subsequences 不同的子序列 Given a string S and a string T...
    99+
    2024-04-02
  • C语言系列之推箱子游戏
    本文实例为大家分享了C语言系列之推箱子游戏的具体代码,供大家参考,具体内容如下 输入WSAD控制行走,只需要把一个方向的代码写好了,剩下的是三个方向就是复制粘贴和简单的修改就可以了。...
    99+
    2024-04-02
  • C#多线程系列之原子操作
    目录知识点竞争条件线程同步CPU时间片和上下文切换阻塞内核模式和用户模式Interlocked类1,出现问题2,Interlocked.Increment()3,Interlocke...
    99+
    2024-04-02
  • 673. 最长递增子序列的个数
    673. 最长递增子序列的个数 原题链接:完成情况:解题思路:方法一:动态规划方法二:贪心 + 前缀和 + 二分查找 参考代码:__673最长递增子序列的个数__动态规划__673最长递增子序列的个数__贪心_前缀和_二分查找...
    99+
    2023-08-30
    代理模式 java 算法 数据结构 leetcode
  • 如何遍历LINQ序列的所有子集
    小编给大家分享一下如何遍历LINQ序列的所有子集,相信大部分人都还不怎么了解,因此分享这篇文章给大家参考一下,希望大家阅读完这篇文章后大有收获,下面让我们一起去了解一下吧!遍历LINQ序列的所有子集有的时候,遍历数组的所有子集很有用。子集和...
    99+
    2023-06-17
  • 【Windows优化系列】Windows11安装Android子系统
    前言 Q:为什么要在Windows安装Android系统?直接在手机使用不好吗? A:在电脑刷酷安不比拿着手机刷酷安爽吗?在电脑版的酷安码字不比手机上码字爽吗?不用打开手机也可以在电脑上点饿了么...
    99+
    2023-09-02
    android windows
  • leetcode 516. 最长回文子序列(JAVA)题解
    题目链接https://leetcode.cn/problems/longest-palindromic-subsequence/description/utm_source=LCUS&utm_medium=ip_redirect&utm_...
    99+
    2023-08-31
    开发语言 java 动态规划 算法
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作