最后给大家献上一个小例子:
--建立自增序列
create sequence seqid
NOMAXvalue
start with 1
increment by 1
nocache
order;
--建立触发器
create or replace trigger tri_test_id
before insert on mytable --<SPAN style="FONT-FAMILY: Arial, Helvetica, sans-serif">mytable</SPAN>为要插入自增序列的表
for each row
declare
nextid number;
begin
IF :new.Id IS NULL or :new.Id=0 THEN --id是要插入自增序列的列名
select seqid.nextval
into nextid
from sys.dual;
:new.Id:=nextid;
end if;
end tri_test_id;
更多Oracle相关信息见Oracle 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=12
