oracle的自增需要依靠序列和触发器共同实现
比如 新建一张表
create
table
test
(id
int
primary
key
,
name
varchar2(10));
创建一个序列
create
sequence
test_seq increment
by
1 start
with
1
minvalue 1 maxvalue 9999999999999 nocache
order
;
触发器实现
create
or
replace
trigger
test_trigger
before
insert
on
test
for
each
row
begin
select
test_seq.Nextval
into
:new.id
from
dual;
end
;
然后插入数据
insert
into
test (
name
)
values
(
‘张三‘
);