Oracle 创建序列:
create sequence SEQ_Tablename_id
increment by 1 --每次增加1
start with 1 --从1开始
nomaxvalue --没有最大值
nocache;
Oracle 查询序列:
select SEQ_Tablename_id.nextvalue from dual
Oracle 建自增长字段触发器:
create or replace trigger type_table_id
before insert on type_table
FOR EACH ROW
declare
max_id NUMBER(10);
begin
SELECT max(ID) INTO max_id FROM type_table;
:NEW.ID := nvl(max_id,0)+1;
end ;
本文介绍了Oracle数据库中序列的创建及使用方法,并演示了如何通过触发器实现表中字段的自增长功能。
1155

被折叠的 条评论
为什么被折叠?



