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

查询表的触发器名称

-- 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;

原文地址:https://www.cnblogs.com/xielinjiang/p/9712102.html