oracle触发器、序列、任务计划练习一例
发表于:2024-10-28 作者:千家信息网编辑
千家信息网最后更新 2024年10月28日,今天在闲暇时间练习了一下oracle任务计划,具体详情如下1.创建表 TBL_TIMEcreate table tbl_time(id number not null, /*id号*/vseco
千家信息网最后更新 2024年10月28日oracle触发器、序列、任务计划练习一例
今天在闲暇时间练习了一下oracle任务计划,具体详情如下
1.创建表 TBL_TIME
create table tbl_time(id number not null, /*id号*/vsecond varchar2(2), /* 秒*/vtime varchar2(10) /*当前时间*/)
2.创建序列 seq_tbltime
create sequence seq_tbltimestart with 1increment by 1nomaxvaluenocyclecache 20
3.创建触发器 tr_tbltimeseq
create or replace trigger tr_tbltimeseq/*功能描述:在插入数据之前利用seq_tbltime序列使表tbl_time(id)实现递增*/before insert on tbl_timefor each row begin select seq_tbltime.nextval into :new.id from dual; end tr_tbltimeseq;
4.创建存储过程 proc_addtime
create or replace procedure proc_addtime/*功能描述:在一分钟之内每过5秒钟向表tbl_time插入当前时间点*/asd_time1 date;d_time2 date;n_timediff number(2);i number(2);begin select sysdate into d_time1 from dual; insert into tbl_time values(1,to_char(d_time1,'ss'),to_char(d_time1,'yyyymmddhhss')); i:=5; while i<=60 loop select sysdate into d_time2 from dual; select round(to_number(d_time2 - d_time1) * 24 * 60 * 60) into n_timediff from dual; if n_timediff=i then insert into tbl_time values(1,to_char(d_time2,'ss'),to_char(d_time2,'yyyymmddhhss')); i:=i+5; end if; end loop; exception when others then rollback; commit;end;
5.创建任务计划
variable n number;/*添加任务计划,该计划立即开始,之后每五分钟执行一次计划任务*/begin dbms_job.submit(:n,'proc_addtime;',sysdate,'sysdate + 5/(24*60)'); commit;end;
执行结果如下
SQL> select * from tbl_time; ID VSECOND VTIME---------- ------- -------------------- 1 09 201407030509 2 14 201407030514 3 19 201407030519 4 24 201407030524 5 29 201407030529 6 34 201407030534 7 39 201407030539 8 44 201407030544 9 49 201407030549
任务
时间
序列
功能
触发器
数据
结果
详情
过程
闲暇
存储
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
以互联网和科技促进均衡发展
饥荒服务器怎么改人物
网络安全手抄报上的插画
我的世界服务器安全系统
ssl vpn服务器搭建
网络安全保障是包括哪些
监控室有几个服务器
宜春稳定服务器怎么样
1130 数据库
网络安全业务怎么盈利
符号位数据库
服务器在资产管理中怎么分类
数字湾区网络安全创新大会
有哪些污小说软件开发
北京ibm服务器回收价格查询
冰点网络安全
校园二手软件开发亮点
服务器局域网怎么弄
分布式框架需要几台服务器
不同类型的数据库
常熟运营网络技术收费
盐城台式机服务器
网易我的世界服务器如何给权限
江西物速达网络技术有限公司
美国科技互联网公司简介
手机软件开发自学难吗
计算机网络技术基础第五版笔记
晋州市天气预报软件开发
网络安全保护等级第三
对数据库自主知识产权的认识