conn scott/tiger@db890
1、创建序列
create sequence foo_id_seq
nocycle
maxvalue 9999999999
start with 1;
2、使用触发器自增
drop table foo;
create table foo(
id number primary key,
data varchar2(100));
create or replace trigger foo_id_pk
before insert
on foo
for each row
begin
select foo_seq.nextval into :new.id from dual;
end;
/
insert into foo(data)
values('Chirstopher');
insert into foo(id,data)
values(5,'Sean');