oracle chain
[oracle@tyger dbs]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Tue May 6 13:02:41 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
/* 创建測试用户tyger 赋予权限 */
SYS@ORCL>drop user tyger cascade;
User dropped.
SYS@ORCL>create user tyger identified by tyger account unlock;
User created.
SYS@ORCL>grant connect,resource to tyger;
Grant succeeded.
SYS@ORCL>conn tyger/tyger
Connected.
/* 创建序列 seq_chain 以及測试表 tab1 tab2 tab3 */
TYGER@ORCL>create sequence seq_chain;
Sequence created.
TYGER@ORCL>create table tab1(id number(5),cdate date,sdate date default sysdate);
Table created.
TYGER@ORCL>create table tab2(id number(5),cdate date,sdate date default sysdate);
Table created.
TYGER@ORCL>create table tab3(id number(5),cdate date,sdate date default sysdate);
Table created.
/* 创建program 报错权限不足 */
TYGER@ORCL>begin
DBMS_SCHEDULER.CREATE_PROGRAM (
program_name => 'CHAIN_P1',
program_type => 'PLSQL_BLOCK',
program_action => 'begin
execute immediate ''insert into tab1(id,cdate)
values(seq_chain.nextval,add_months(sysdate,seq_chain.currval))'';
end;',
enabled => true);
end;
/
2 3 4 5 6 7 8 9 10 11
*
ERROR at line 1:
ORA-27486: insufficient privileges
ORA-06512: at "SYS.DBMS_ISCHED", line 5
ORA-06512: at "SYS.DBMS_SCHEDULER", line 30
ORA-06512: at line 2
/* 赋予必要权限 以及接下去实验须要的权限 */
TYGER@ORCL>conn / as sysdba
Connected.
SYS@ORCL>grant create job to tyger;
Grant succeeded.
SYS@ORCL>grant create evaluation context to tyger;
Grant succeeded.
SYS@ORCL>grant create rule set to tyger;
Grant succeeded.
SYS@ORCL>grant create rule to tyger;
Grant succeeded.
/* 创建program */
SYS@ORCL>conn tyger/tyger
Connected.
TYGER@ORCL>begin
DBMS_SCHEDULER.CREATE_PROGRAM (
program_name => 'CHAIN_P1',
program_type => 'PLSQL_BLOCK',
program_action => 'begin
execute immediate ''insert into tab1(id,cdate)
values(seq_chain.nextval,add_months(sysdate,seq_chain.currval))'';
end;',
enabled => true);
end;
/
2 3 4 5 6 7 8 9 10 11
PL/SQL procedure successfully completed.
TYGER@ORCL>begin
DBMS_SCHEDULER.CREATE_PROGRAM (
program_name => 'chain_step2',
program_type => 'PLSQL_BLOCK',
program_action => 'begin
execute immediate ''insert into tab2(id,cdate)
values(seq_chain.nextval,add_months(sysdate,seq_chain.currval))'';
end;',
enabled => true);
end;
/
2 3 4 5 6 7 8 9 10 11
PL/SQL procedure successfully completed.
TYGER@ORCL>begin
DBMS_SCHEDULER.CREATE_PROGRAM (
program_name => 'CHAIN_P3',
program_type => 'PLSQL_BLOCK',
program_action => 'begin
execute immediate ''insert into tab3(id,cdate)
values(seq_chain.nextval,add_months(sysdate,seq_chain.currval))'';
end;',
enabled => true);
end;
/
2 3 4 5 6 7 8 9 10 11
PL/SQL procedure successfully completed.
/* 创建链tyger_chain */
TYGER@ORCL>exec dbms_scheduler.create_chain('tyger_chain');
PL/SQL procedure successfully completed.
TYGER@ORCL>select chain_name from user_scheduler_chains;
CHAIN_NAME
------------------------------
TYGER_CHAIN
/* 创建chain step
为链TYGER_CHAIN 加入step ,能够一个一个的加入,也能够一下所有加入 */
TYGER@ORCL>
TYGER@ORCL>begin
dbms_scheduler.define_chain_step(
chain_name =>'TYGER_CHAIN',
step_name =>'CHAIN_STEP1',
program_name => 'CHAIN_P1');
end;
/
2 3 4 5 6 7
PL/SQL procedure successfully completed.
TYGER@ORCL>begin
dbms_scheduler.define_chain_step(
chain_name =>'TYGER_CHAIN',
step_name =>'CHAIN_STEP2',
program_name => 'chain_step2');
dbms_scheduler.define_chain_step(
chain_name =>'TYGER_CHAIN',
step_name =>'chain_step3',
program_name => 'CHAIN_P3');
end;
/
2 3 4 5 6 7 8 9 10 11
PL/SQL procedure successfully completed.
/* 查看创建的step 是否成功 */
TYGER@ORCL>col chain_name for a16
TYGER@ORCL>col step_name for a16
TYGER@ORCL>col program_name for a16
TYGER@ORCL>select chain_name,step_name,program_name
2 from user_scheduler_chain_steps;
CHAIN_NAME STEP_NAME PROGRAM_NAME
---------------- ---------------- ----------------
TYGER_CHAIN CHAIN_STEP1 CHAIN_P1
TYGER_CHAIN CHAIN_STEP2 CHAIN_P2
TYGER_CHAIN CHAIN_STEP3 CHAIN_P3
/* 为链创建规则 */
/* 规则:首先运行 chain_step1,成功完毕后运行 chain_step2 ,成功完毕后运行 chain_step3,成功完毕后,结束。 */
TYGER@ORCL>
TYGER@ORCL>begin
DBMS_SCHEDULER.DEFINE_CHAIN_RULE (
chain_name => 'TYGER_CHAIN',
condition => 'true',
action => 'start CHAIN_STEP1',
rule_name => 'rule_01');
DBMS_SCHEDULER.DEFINE_CHAIN_RULE (
chain_name => 'TYGER_CHAIN',
condition => 'CHAIN_STEP1 SUCCEEDED',
action => 'start chain_step2',
rule_name => 'rule_02');
DBMS_SCHEDULER.DEFINE_CHAIN_RULE (
chain_name => 'TYGER_CHAIN',
condition => 'chain_step2 SUCCEEDED',
action => 'start chain_step3',
rule_name => 'rule_03');
DBMS_SCHEDULER.DEFINE_CHAIN_RULE (
chain_name => 'TYGER_CHAIN',
condition => 'chain_step3 SUCCEEDED',
action => 'END 0',
rule_name => 'rule_04');
END;
/
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
PL/SQL procedure successfully completed.
/* 启用链 tyger_chain */
TYGER@ORCL>exec dbms_scheduler.enable('TYGER_CHAIN');
PL/SQL procedure successfully completed.
手动执行链 tyger_chain
TYGER@ORCL>begin
DBMS_SCHEDULER.RUN_CHAIN (
chain_name =>'TYGER_CHAIN',
start_steps =>'CHAIN_STEP1');
end;
/
2 3 4 5 6
PL/SQL procedure successfully completed.
/* 验证
是不是依照我们设计的规则 tab1 -> tab2 -> tab3 ->exit 完毕的。
*/
TYGER@ORCL>alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
Session altered.
TYGER@ORCL>select * from tab1;
ID CDATE SDATE
---------- ------------------- -------------------
1 2014-06-06 13:14:24 2014-05-06 13:14:24
TYGER@ORCL>select * from tab2;
ID CDATE SDATE
---------- ------------------- -------------------
2 2014-07-06 13:14:25 2014-05-06 13:14:25
TYGER@ORCL>select * from tab3;
ID CDATE SDATE
---------- ------------------- -------------------
3 2014-08-06 13:14:25 2014-05-06 13:14:25
TYGER@ORCL>
oracle chain的更多相关文章
- EOS 资源汇总
EOS 资源汇总 A curated list of EOS Ecosystem by [SuperONE](https://superone.io/) EOS 主网 超级节点 https:/ ...
- oracle锁等级以及解锁
以下是两遍关于锁的介绍的文章,第一篇介绍锁等级以及常用操作,第二篇主要介绍了oracle中两个用以查询数据库任意对象的两个视图 一: http://www.cnblogs.com/lguyss/arc ...
- Oracle Tuning 基础概述01 - Oracle 常见等待事件
对Oracle数据库整体性能的优化,首先要关注的是在有性能问题时数据库排名前几位等待事件是哪些.Oracle等待事件众多,随着版本的升级,数量还在不断增加,可以通过v$event_name查到当前数据 ...
- Oracle Database 11g Release 2(11.2.0.3.0) RAC On Redhat Linux 5.8 Using Vmware Workstation 9.0
一,简介 二,配置虚拟机 1,创建虚拟机 (1)添加三块儿网卡: 主节点 二节点 eth0: 公网 192.168.1.20/24 NAT eth0: 公网 192.168.1 ...
- [转]Oracle数据块体系的详细介绍
数据块概述Oracle对数据库数据文件(datafile)中的存储空间进行管理的单位是数据块(data block).数据块是数据库中最小的(逻辑)数据单位.与数据块对应的,所有数据在操作系统级的最小 ...
- oracle实例恢复之检查点队列
chain即链. oracle中链有很多种,LRU.LRUW.checkpoint queue等,都是干什么的呢??? LRU将可用块(干净的块)串起来.LRUW将脏块串起来,指导DBWR进程率先将冷 ...
- ORACLE工作原理小结
ORACLE工作原理1-连接 我们从一个用户请求开始讲,ORACLE的完整的工作机制是怎样的,首先一个用户进程发出一个连接请求,如果使用的是主机命名或者是本地服务命中的主机名使用的是机器名(非IP地址 ...
- Oracle EBS R12 (12.1.3) Installation Linux(64 bit)
Oracle EBS R12 (12.1.3) Installation Linux(64 bit) Contents Objective. 3 1 Download & Unzip. 3 D ...
- Oracle Hang分析--转载
1. 数据库hang的几种可能性 oracle 死锁 或者系统负载非常高比如cpu使用或其他一些锁等待很高都可能导致系统hang住,比如大量的DX锁. 通常来说,我们所指的系统hang住,是指应用无响 ...
随机推荐
- bat 处理文件路径 (所在目录,文件名,文件后缀名,完整文件名,无后缀路径)
echo off setlocal enabledelayedexpansion set "EXCEL_DIR=%cd%\excel" for /R %EXCEL_DIR% %%f ...
- 微信小程序 - 替换tabbar(采用固定定位形式)
简单示例(提供思路): wxml(作为模板形式插入到需要tabbar的地方去) <view class='tab-bar'> <view class="usermotto& ...
- Laravel之视图和Blade模板引擎
一.视图 1.视图文件存放在resources/views目录2.视图载入及传参 return view('greeting', ['name' => 'James']); 还可以通过with ...
- 开发ionic准备之安卓模拟器设置(2)
发现这个安卓模拟器设置屏幕还不能太大,太大显示不全,然后整个模拟器不能拖动,所以尽量不要设置太大的分辨率 ,如下即可 如果选安卓4.4然后勾选了其他下面的ok还不能点击的话,这下要去sdk manag ...
- linux服务器性能检测工具nmon使用
今天介绍一款linux系统服务器性能检测的工具-nmon及nmon_analyser (生成性能报告的免费工具),亲测可用. 一.介绍 nmon 工具可以帮助在一个屏幕上显示所有重要的性能优化信息,并 ...
- iOS仿支付宝首页的刷新布局效果
代码地址如下:http://www.demodashi.com/demo/12753.html XYAlipayRefreshDemo 运行效果 动画效果分析 1.UI需要变动,向上滑动的时候,顶部部 ...
- .Net、C# 汉字转拼音,简体繁体转换方法
Visual Studio International Pack 包含一组类库,该类库扩展了.NET Framework对全球化软件开发的支持.使用该类库提供的类,.NET 开发人员可以更方便的创建支 ...
- 1 android 人脸识别
1 https://www.google.com.hk/search?newwindow=1&safe=strict&q=android+%E5%9B%BE%E7%89%87%E4%B ...
- 类中的internal成员可能是一种坏味道
前言 最近除了搞ASP.NET MVC之外,我也在思考一些编程实践方面的问题.昨天在回家路上,我忽然对一个问题产生了较为清晰的认识.或者说,原先只是有一丝细微的感觉,而现在将它和一些其他的方面进行了联 ...
- struts2中怎样处理404?
眼下在做一个网络应用程序,struts2 + spring + hibernate,server是tomcat.希望用户在IE地址栏乱敲的时候.所敲入的全部没有定义的URL都能被程序捕捉到,然后转到一 ...