熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> Oracle >> 正文

Oracle使用觸發器實現自增ID

2013-11-13 15:52:50  來源: Oracle 

  userinfo表id需要實現自增效果

  創建序列

  代碼

   Create sequence

  create sequence seq_userinfo

  minvalue

  start with

  increment by ;

  創建觸發器

  代碼

  create or replace trigger tigger_userinfo

  before insert on userinfo

  for each row

  declare

  begin

  select SEQ_userinfonextval into:Newid from dual;

  end tigger_userinfo;


From:http://tw.wingwit.com/Article/program/Oracle/201311/17447.html
    Copyright © 2005-2013 電腦知識網 Computer Knowledge   All rights reserved.