DBMS_JOB

Oracle 定时任务详解(dbms_job 文章目录1 概述2 dbms_job2.1 提交2.2 暂停2.3 修改2.4 运行2.5 删除 1 概述 1. 数据来源包:dbms_jobOracle 10g 前常用 2. 目前已被 dbms_scheduler 所取代,且 Oracle 建议使用 dbms_scheduler 扩展:Oracle 定时任务详解(dbms_scheduler) 2 dbms_job 1. 查看数据库中定时任务的最多并发数(默认:1000) (1) show parameter job_queue_pro 阅读详情
导读:




The DBMS_JOB package schedules and manages jobs in the job queue.



Note:


The DBMS_JOB package has been superseded by the DBMS_SCHEDULER package. In particular, if you are administering jobs to manage system load, you should consider disabling DBMS_JOB by revoking the package execution privilege for users.

For more information, see Chapter 93, "DBMS_SCHEDULER" and "Moving from DBMS_JOB to DBMS_SCHEDULER" in Oracle Database Administrator's Guide.



This chapter contains the following topics:







Using DBMS_JOB






Security Model


No specific system privileges are required to use DBMS_JOB. No system privileges are available to manage DBMS_JOB.
Jobs cannot be altered or deleted other than jobs owned by the user.
This is true for all users including those users granted DBA privileges.


You can execute procedures that are owned by the user or for which the user is explicitly granted EXECUTE. However, procedures for which the user is granted the execute privilege through roles cannot be executed.


Note that, once a job is started and running, there is no easy way to stop the job.





Operational Notes




Working with Real Application Clusters

DBMS_JOB supports multi-instance execution of jobs. By
default jobs can be executed on any instance, but only one single
instance will execute the job. In addition, you can force instance
binding by binding the job to a particular instance. You implement
instance binding by specifying an instance number to the instance
affinity parameter. Note, however, that in Oracle Database 10g Release
1 (10.1) instance binding is not recommended. Service affinity is
preferred. This concept is implemented in the DBMS_SCHEDULER package.


The following procedures can be used to create, alter or run jobs
with instance affinity. Note that not specifying affinity means any
instance can run the job.



DBMS_JOB.SUBMIT

To submit a job to the job queue, use the following syntax:


DBMS_JOB.SUBMIT( 
job OUT BINARY_INTEGER,
what IN VARCHAR2, NEXT_DATE IN DATE DEFAULTSYSDATE,
interval IN VARCHAR2 DEFAULT 'NULL',
no_parse IN BOOLEAN DEFAULT FALSE,
instance IN BINARY_INTEGER DEFAULT ANY_INSTANCE,
force IN BOOLEAN DEFAULT FALSE);

Use the parameters instance and force to control job and instance affinity. The default value of instance is 0 (zero) to indicate that any instance can execute the job. To run the job on a certain instance, specify the instance value. Oracle displays error ORA-23319 if the instance value is a negative number or NULL.


The force parameter defaults to false. If force is TRUE, any positive integer is acceptable as the job instance. If force is FALSE, the specified instance must be running, or Oracle displays error number ORA-23428.





DBMS_JOB.INSTANCE

To assign a particular instance to execute a job, use the following syntax:


DBMS_JOB.INSTANCE(  JOB IN BINARY_INTEGER,
instance IN BINARY_INTEGER,
force IN BOOLEAN DEFAULT FALSE);

The FORCE parameter in this example defaults to FALSE.
If the instance value is 0 (zero), job affinity is altered and any
available instance can execute the job despite the value of force. If
the INSTANCE value is positive and the FORCE parameter is FALSE, job affinity is altered only if the specified instance is running, or Oracle displays error ORA-23428.


If the force parameter is TRUE, any
positive integer is acceptable as the job instance and the job affinity
is altered. Oracle displays error ORA-23319 if the instance value is negative or NULL.





DBMS_JOB.CHANGE

To alter user-definable parameters associated with a job, use the following syntax:


DBMS_JOB.CHANGE(  JOB IN BINARY_INTEGER,
what IN VARCHAR2 DEFAULT NULL,
next_date IN DATE DEFAULT NULL,
interval IN VARCHAR2 DEFAULT NULL,
instance IN BINARY_INTEGER DEFAULT NULL,
force IN BOOLEAN DEFAULT FALSE );

Two parameters, instance and force, appear in this example. The default value of instance is null indicating that job affinity will not change.


The default value of force is FALSE. Oracle displays error ORA-23428 if the specified instance is not running and error ORA-23319 if the instance number is negative.





DBMS_JOB.RUN

The force parameter for DBMS_JOB.RUN defaults to FALSE. If force is TRUE, instance affinity is irrelevant for running jobs in the foreground process. If force is FALSE, the job can run in the foreground only in the specified instance. Oracle displays error ORA-23428 if force is FALSE and the connected instance is the incorrect instance.


DBMS_JOB.RUN( 
job IN BINARY_INTEGER,
force IN BOOLEAN DEFAULT FALSE);




Stopping a Job

Note that, once a job is started and running, there is no easy way to stop the job.








Summary of DBMS_JOB Subprograms



Table 48-1 DBMS_JOB Package Subprograms



















































SubprogramDescription

BROKEN Procedure



Disables job execution



CHANGE Procedure



Alters any of the user-definable parameters associated with a job



INSTANCE Procedure



Assigns a job to be run by a instance



INTERVAL Procedure



Alters the interval between executions for a specified job



NEXT_DATE Procedure



Alters the next execution time for a specified job



REMOVE Procedure



Removes specified job from the job queue



RUN Procedure



Forces a specified job to run



SUBMIT Procedure



Submits a new job to the job queue



USER_EXPORT Procedures



Re-creates a given job for export, or re-creates a given job for export with instance affinity



WHAT Procedure



Alters the job description for a specified job









BROKEN Procedure


This procedure sets the broken flag. Broken jobs are never run.



Syntax


DBMS_JOB.BROKEN ( 
job IN BINARY_INTEGER,
broken IN BOOLEAN,
next_date IN DATE DEFAULT SYSDATE);


Parameters



Table 48-2 BROKEN Procedure Parameters























ParameterDescription

job



Number of the job being run.



broken



Job broken: IN value is FALSE.



next_data



Date of the next refresh.







Note:


If you set job as broken while it is running, Oracle resets the job's
status to normal after the job completes. Therefore, only execute this
procedure for jobs that are not running.


Usage Notes


You must issue a COMMIT statement immediately after the statement.





CHANGE Procedure


This procedure changes any of the fields a user can set in a job.



Syntax


DBMS_JOB.CHANGE ( 
job IN BINARY_INTEGER,
what IN VARCHAR2,
next_date IN DATE,
interval IN VARCHAR2,
instance IN BINARY_INTEGER DEFAULT NULL,
force IN BOOLEAN DEFAULT FALSE);


Parameters



Table 48-3 CHANGE Procedure Parameters



































ParameterDescription

job



Number of the job being run.



what



PL/SQL procedure to run.



next_date



Date of the next refresh.



interval



Date function; evaluated immediately before the job starts running.



instance



When a job is submitted, specifies which instance can run the job. This defaults to NULL, which indicates that instance affinity is not changed.



force



If this is FALSE, then the specified instance (to which the instance number change) must be running. Otherwise, the routine raises an exception.


If this is TRUE, then any positive integer is acceptable as the job instance.







Usage Notes



  • You must issue a COMMIT statement immediately after the statement.



  • The parameters instance and force are
    added for job queue affinity. Job queue affinity gives users the
    ability to indicate whether a particular instance or any instance can
    run a submitted job.



  • If the parameters what, next_date, or interval are NULL, then leave that value as it is.




Example


BEGIN
DBMS_JOB.CHANGE(14144, null, null, 'sysdate+3');
COMMIT;
END;




INSTANCE Procedure


This procedure changes job instance affinity.



Syntax


DBMS_JOB.INSTANCE ( 
job IN BINARY_INTEGER,
instance IN BINARY_INTEGER,
force IN BOOLEAN DEFAULT FALSE);


Parameters



Table 48-4 INSTANCE Procedure Parameters























ParameterDescription

job



Number of the job being run.



instance



When a job is submitted, a user can specify which instance can run the job.



force



If this is TRUE, then any positive integer is acceptable as the job instance. If this is FALSE (the default), then the specified instance must be running; otherwise the routine raises an exception.







Usage Notes


You must issue a COMMIT statement immediately after the statement.





INTERVAL Procedure


This procedure changes how often a job runs.



Syntax


DBMS_JOB.INTERVAL ( 
job IN BINARY_INTEGER,
interval IN VARCHAR2);


Parameters



Table 48-5 INTERVAL Procedure Parameters



















ParameterDescription

job



Number of the job being run.



interval



Date function, evaluated immediately before the job starts running.







Usage Notes



  • If the job completes successfully, then this new date is placed in next_date. interval is evaluated by plugging it into the statement select interval into next_date from dual;



  • The interval parameter must evaluate to a time in the future. Legal intervals include:
























    IntervalDescription
    'sysdate + 7'Run once a week.
    'next_day(sysdate,'TUESDAY')'Run once every Tuesday.
    'null'Run only once.




  • If interval evaluates to NULL and if a job completes successfully, then the job is automatically deleted from the queue.



  • You must issue a COMMIT statement immediately after the statement.






NEXT_DATE Procedure


This procedure changes when an existing job next runs.



Syntax


DBMS_JOB.NEXT_DATE ( 
job IN BINARY_INTEGER,
next_date IN DATE);


Parameters



Table 48-6 NEXT_DATE Procedure Parameters



















ParameterDescription

job



Number of the job being run.



next_date



Date of the next refresh: it is when the job will be automatically
run, assuming there are background processes attempting to run it.







Usage Notes


You must issue a COMMIT statement immediately after the statement.





REMOVE Procedure


This procedure removes an existing job from the job queue. This currently does not stop a running job.



Syntax


DBMS_JOB.REMOVE ( 
job IN BINARY_INTEGER );


Parameters



Table 48-7 REMOVE Procedure Parameters















ParameterDescription

job



Number of the job being run.







Usage Notes


You must issue a COMMIT statement immediately after the statement.



Example


BEGIN
DBMS_JOB.REMOVE(14144);
COMMIT;
END;




RUN Procedure


This procedure runs job JOB now. It runs it even if it is broken.


Running the job recomputes next_date. See view user_jobs.



Syntax


DBMS_JOB.RUN ( 
job IN BINARY_INTEGER,
force IN BOOLEAN DEFAULT FALSE);


Parameters



Table 48-8 RUN Procedure Parameters



















ParameterDescription

job



Number of the job being run.



force



If this is TRUE, then instance affinity is irrelevant for running jobs in the foreground process. If this is FALSE, then the job can be run in the foreground only in the specified instance.







Example


EXECUTE DBMS_JOB.RUN(14144);


Caution:


This re-initializes the current session's packages.




Exceptions


An exception is raised if force is FALSE, and if the connected instance is the wrong one.





SUBMIT Procedure


This procedure submits a new job. It chooses the job from the sequence sys.jobseq.



Syntax


DBMS_JOB.SUBMIT ( 
job OUT BINARY_INTEGER,
what IN VARCHAR2,
next_date IN DATE DEFAULT sysdate,
interval IN VARCHAR2 DEFAULT 'null',
no_parse IN BOOLEAN DEFAULT FALSE,
instance IN BINARY_INTEGER DEFAULT any_instance,
force IN BOOLEAN DEFAULT FALSE);


Parameters



Table 48-9 SUBMIT Procedure Parameters







































ParameterDescription

job



Number of the job being run.



what



PL/SQL procedure to run.



next_date



Next date when the job will be run.



interval



Date function that calculates the next time to run the job. The default is NULL. This must evaluate to a either a future point in time or NULL.



no_parse



A flag. The default is FALSE. If this is set to FALSE, then Oracle parses the procedure associated with the job. If this is set to TRUE, then Oracle parses the procedure associated with the job the first time that the job is run.


For example, if you want to submit a job before you have created the tables associated with the job, then set this to TRUE.



instance



When a job is submitted, specifies which instance can run the job.



force



If this is TRUE, then any positive integer is acceptable as the job instance. If this is FALSE (the default), then the specified instance must be running; otherwise the routine raises an exception.







Usage Notes



  • You must issue a COMMIT statement immediately after the statement.



  • The parameters instance and force are
    added for job queue affinity. Job queue affinity gives users the
    ability to indicate whether a particular instance or any instance can
    run a submitted job.




Example


This submits a new job to the job queue. The job calls the procedure DBMS_DDL.ANALYZE_OBJECT to generate optimizer statistics for the table DQUON.ACCOUNTS. The statistics are based on a sample of half the rows of the ACCOUNTS table. The job is run every 24 hours:


VARIABLE jobno number;
BEGIN
DBMS_JOB.SUBMIT(:jobno,
'dbms_ddl.analyze_object('TABLE',
'DQUON', 'ACCOUNTS',
'ESTIMATE', NULL, 50);'
SYSDATE, 'SYSDATE + 1');
COMMIT;
END;
/
Statement processed.
print jobno
JOBNO
----------
14144




USER_EXPORT Procedures


There are two overloaded procedures. The first produces the text of
a call to re-create the given job. The second alters instance affinity
(8i and after) and preserves the compatibility.



Syntax


DBMS_JOB.USER_EXPORT ( 
job IN BINARY_INTEGER,
mycall IN OUT VARCHAR2);

DBMS_JOB.USER_EXPORT (
job IN BINARY_INTEGER,
mycall IN OUT VARCHAR2,
myinst IN OUT VARCHAR2);


Parameters



Table 48-10 USER_EXPORT Procedure Parameter























ParameterDescription

job



Number of the job being run.



mycall



Text of a call to re-create the given job.



myinst



Text of a call to alter instance affinity.









WHAT Procedure


This procedure changes what an existing job does, and replaces its environment.



Syntax


DBMS_JOB.WHAT ( 
job IN BINARY_INTEGER,
what IN VARCHAR2);


Parameters



Table 48-11 WHAT Procedure Parameters



















ParameterDescription

job



Number of the job being run.



what



PL/SQL procedure to run.







Usage Notes



  • You must issue a COMMIT statement immediately after the statement.



  • Some legal values of what (assuming the routines exist) are:



    • 'myproc('10-JAN-82', next_date, broken);'



    • 'scott.emppackage.give_raise('JENKINS', 30000.00);'



    • 'dbms_job.remove(job);'





本文转自

http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14258/d_job.htm
YOLO模型使用jupyterlab的方式进行预测/推理(示例) 首先相信很多使用过python的人都或多或少地了解过这个应用。是一个开源Web应用程序,可让用户创建和共享包含实时代码、公式、可视化和叙述文本的文档。用途包括:数据清理和转换、数值模拟、统计建模、等等。而Jupyter Lab则是Jupyter的下一代笔记本界面。是一个基于Web的交互式开发环境,用于Jupyter notebook、代码和数据。非常灵活,可支持数据科学、科学计算和机器学习领域的广泛工作。是可扩展和模块化的,其可编写插件来添加新组件并与现有组件相集成。 阅读详情

相关推荐

ArcGIS Pro符号化教程

本文详细介绍了ArcGIS Pro的软件设置和符号化操作步骤。主要包括:1)设置默认工程目录和关闭地图自动加载;2)创建新工程的基本流程;3)点要素的单一符号化方法,包括样式修改和图层调整;4)图表符号显示过滤器的使用,涉及字段添加、图表类型选择和背景设置。文章还提供了操作截图和数据下载链接,适合GIS初学者学习ArcGIS Pro的基础符号化操作。

WwLK123的博客 513

5.dbms_job管理

3 DBMS_JOB和生产应用。

weixin_42005129的博客 1433

【RAC】rac中如何指定job的运行实例.pdf

【RAC】rac中如何指定job的运行实例.pdf【RAC】rac中如何指定job的运行实例.pdf【RAC】rac中如何指定job的运行实例.pdf

Oracle笔记十九:内置包

DBMS_LOB.substr、dbms_metadata.get_ddl、dbms_output.put_line、dbms_random.random、DBMS_RANDOM.STRING

Mavey__的博客 2903

Oracle基础包之DBMS_JOB(二)

1、概述 DBMS_JOB包包含isubmit、submit、remove、change、what、next_date、instance、interval、broken、run、user_export等过程。主要用于安排和管理作业队列,通过使用作业,可以使ORACLE数据库定期执行特定的任务,这个包属于系统用户sys 2、包的构成 2.1、isubmit 和submit 说明: 此过程用于建立一个新作业。 注意事项: 当建立作业时,需要给作业要执行的操作,作业的下次运行日期及运行时间间隔。 语法

tianxingyun的专栏 935

PL/SQL:学会使用DBMS_JOB

一、DBMS_JOB包的使用     DBMS_JOB包用于安排和管理作业队列.通过使用作业,可以使ORACLE数据库定期执行特定的任务.     注意:使用DBMS_JOB管理作业时,必须确保设置初始化参数JOB_QUEUE_PROCESSES(不能为0)   1.SUBMIT     该过程用于建立一个新作业,当建立作业时,需要给出作业要执行的操作,作业的下次运行日期及时间间隔.

ORACLE FANS的专栏 5367

dbms_job

/* dbms_job包; 用于安排和管理作业队列。 通过使用队列,是oracle数据库定期执行特定的任务; */– 1,submit /* 该过程用于建立一个作业 需要给出作业的操作,下一次运行时间,时间间隔 */begin dbms_job.submit( :jobno,what ,next_date ,in

weixin_36408281的博客 475

dbms_jobdbms_job基础学习

一、dbms_job学习 a、创建job: dbms_job.submit(jobno,what,next_date,interval); b、删除job: dbms_job.remove(jobno);  c、修改要执行的操作: job:dbms_job.what(jobno, what);  d、修改下次执行时间:dbms_job.next_date(jobno, next_date); ...

1480

oracledbms_job的使用

一、设置初始化参数 job_queue_processessql> alter system set job_queue_processes=n;(n>0)job_queue_processes最大值为1000查看job queue 后台进程sql>select name,description from v$bgprocess;或者sql>show parameter job_queue_processes;二、dbms_job package 用法介绍1、Broken()过程更新一个已提交的工作的状态,

nsj820的专栏 1万+

dbms_jobdbms_ijob

工作中可能遇到这样的情况,在A用户下有一个不用的job,但是dba不知道A用户的密码,怎么删除这个job呢。 相信大部分人都会尝试在sys用户下用dbms_job.remove()命令去删除它,但是会报错 sys用户下 SQL> exec dbms_job.remove(70); BEGIN dbms_job.remove(70); END; * ERROR at line 1...

cdenji的博客 1398

Oracle DBMS_SCHEDULER 与 DBMS_JOB 的对比

DBMS_JOB仅支持PL/SQL代码片段无正式作业名称,只有数字IDBEGINEND;',END;支持命名作业可执行PL/SQL块、存储过程、外部程序等支持作业链、作业类等高级概念BEGINEND;',END;

文牧之的博客 1401

Oracle进阶(四)DBMS_JobDBMS_Scheduler

1、JobDBMS_Job 概述 Oralce中的任务有2种:JobDBMS_job,区别: 1、jobsoracle数据库的对象,dbms_jobsjobs对象的一个实例,类比emp表是tables的实例。 2、创建方式有差异,Job是通过调用dbms_scheduler.create_job包创建的,Dbms_job则是通过调用dbms_job.submit包创建的。

一二山人的博客 3093

oracle sys.dbms job,DBMS_JOB,dbms_ijob用法

dbms_job只能在job的所在用户使用,如果broken其它用户的jobdbms_ijobLGEHNP:/data01/app/oracle/product/9.2.0> sqlplus "/as sysdba"SQL*Plus: Release 9.2.0.8.0 - Production on Mon Aug 9 13:54:15 2010Copyright (c) 1982, 2...

weixin_39921087的博客 799

转换dbms_jobdbms_scheduler

- 通过查询,和观察实际插入的数据,是每天13:30,执行存储过程一次,也就是每天13:30运行一次job。-- 2 创建dbms_scheduler job ## 每天的13:30 运行一次。1 获取dbms_job的ddl语句,使用 dbms_job.user_export。--3 确认scheduler job (每天13:30 执行一次)-- 4 drop掉原来的job

文档搬运工 486

DBMS_Job包的用法

DBMS_Job包的用法  包含以下子过程: Broken()过程。change()过程。Interval()过程。Isubmit()过程。Next_Date()过程。Remove()过程。Run()过程。Submit()过程。User_Export()过程。What()过程。1、Broken()过程更新一个已提交的工作的状态,典型地是用来把一个已破工作标记为未破工作。这个过程有三个参

bjguan's BLOG 895

建立物化视图出现ORA-23319错误

一个物化视图创建的小bug,在NEXT语句后面不能使用“—”开始的注释。否则报错ORA-23319。 模拟错误: SQL> SELECT * FROM V$VERSION; BANNER---------...

ckawt40802的专栏 1165

ORA-12889,ORA-23319 when creating materialized view

创建mv时,mv的定义会保存到sys.snap$中。 mv的next参数保存在sys.snap$的auto_fun列,此列最大长度为200. 如果next参数后面有注释,那么注释也会一并保存到auto_fun列。 ...

cuichanpi8600的博客 799

oracle job调度,Oracle任务调度之DMBS_JOB

DBMS_JOB是对任务队列进行调度和管理的包DBMS_JOB已经废除,由DBMS_SCHEDULER取代,推荐使用DBMS_SCHEDULER你应该要撤销用户对DBMS_JOB的包执行权限来禁止DBMS_JOB的使用1. 安全模型使用DBMS_JOB不需要特别的系统权限,只有jobs的拥有者才能对jobs进行修改或删除. 只有procedures的拥有者或直接被授权对该procedures可执行...

weixin_39672011的博客 409

RAC中指定job运行实例

<br />统计RAC库晚上运行了很多job,由于没给job指定固定的实例。部分job会<br />同时在一个实例上运行。导致job不能按时完成。通过dbms_job.instance()<br />将job固定在某个实例上,避免多个job同时被分配到一个实例上。<br /> <br /> <br />Connected to Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 <br />Connected as careport<br />

lwei_998的专栏 4382

Oracle PL/SQL进阶编程(第九弹:使用系统包:DBMS_JOB

Oracle开发中,经常需要对一些任务进行调度。在Oracle中,调度任务又称为作业,只要是使用DBMS_JOB包来实现的。 创建作业SUBMIT 这个过程用来创建一个作业,并且输出作业号码。当建立新的作业时,需要给出作业要执行的操作,作业在下一次运行的日期及运行的时间间隔,语法如下: PROCEDURE SUBMIT(job OUT BINARY_INTEGER, ...

艺术就是爆炸的专栏 609

IEC 60947-6-1-2021 低压开关设备和控制设备第6-1部分:多功能设备转换开关设备.pdf

IEC 60947-6-1-2021 低压开关设备和控制设备第6-1部分:多功能设备转换开关设备.pdf

上一篇: 自动邮件发送博客文章的WordPress插件
下一篇: Unix Crontab - setting up cron jobs using crontab
Xviewee
博客等级 码龄19年 77粉丝 236原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值