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 ;