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;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM