1。先创建一个序列:
create sequence mytable_sequence
start with 1
increment by 1
2.给表创建触发器:
create or replace trigger mytable_trg
before insert on mytable
for each row
begin
select mytable_sequence.nextval into new.id from dual;
end;
insert into mytable(name) values('ddd');
这样id就会自动插进去,跟mysql中设的自动编号一样了。