Oracle???????????sequence
???????????? ???????[ 2013/3/14 11:30:24 ] ????????
????Oracle?????sqlserver?????????????????У?????????sqlserver??????Ч???????????鷳????????????????????SEQUENCE?????????????????ɡ?
????CREATE SEQUENCE emp_sequence
????INCREMENT BY 1 -- ??????????????????1
????START WITH 1 -- ??1???????
????NOMAXvalue -- ????????????????????????MAXvalue ??????????????
????NOCYCLE -- ???????????
????NOCACHE ; --????????棬????????????????MAXvalue
??????????emp_sequence?????????CURRVAL??NEXTVAL??CURRVAL=???? sequence???????NEXTVAL=????sequence?????????? sequence ???
???????磺
????emp_sequence.CURRVAL ??emp_sequence.NEXTVAL
???????????sequence??????
????????????????snapshot??view?? SELECT ???
????INSERT??????????
????NSERT????values??
????UPDATE ?? set??
???????
?????????NEXTVAL????????????????NEXTVAL?????????????????????????????????CURRVAL ?????????SEQUENCE???????????????NEXTVAL??????????????CURRVAL??????????????NEXTVAL????????? SEQUENCE????????????????????????????????NEXTVAL?????????????????
??????????cache???Oracle????????????????????Щsequence????????????Щ??cache?????????Oracle????????鵽cache?? ???cache?????????? ?????????????????down???shutdown abort)??cache?е?sequence???. ?????????create sequence???????nocache????????????
?????????????Sequence????????????????????alter??drop??
?????????????????С?????
--????????????
create sequence seqid
NOMAXvalue
start with 1
increment by 1
nocache
order;
--??????????
create or replace trigger tri_test_id
before insert on mytable --mytable?????????????е??
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;
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11