加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

oracle 序列和触发器的查看的新建 以及使用

发布时间:2020-12-12 13:45:16 所属栏目:百科 来源:网络整理
导读:查询表的触发器名称 -- select trigger_name from all_triggers where table_name=‘表名‘; 查询触发器的详细内容 -- select text from all_source where type=‘TRIGGER‘ AND name=‘触发器名称‘; --查看所有的序列 -- select * from user_sequences; --

查询表的触发器名称

-- select trigger_name from all_triggers where table_name=‘表名‘;

查询触发器的详细内容
-- select text from all_source where type=‘TRIGGER‘ AND name=‘触发器名称‘;

--查看所有的序列

-- select * from user_sequences;

--查看序列的下一个值

select DICTIONARY_SEQ.Nextval from dual;

--查看序列的当前值 该语句需要和nextval在同一个回话中使用
select DICTIONARY_SEQ.CURRVAL from dual;


--创建序列

create sequence 序列名称
minvalue 1 --最小值
maxvalue 9999999999999999999999999999? --最大值
start with 1? --从那个值开始
increment by 1 --步长 每次增加多少
nocache;

?

--创建触发器

create or replace trigger 触发器名称
before insert(在什么时候触发 insert 插入的时候触发)? on 表名? ?
for each row
begin

--触发的时候执行的sql?

例如查询序列 赋值到id列
? select a.nextval into :new.Id from dual;

end;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读