步骤 2 : 使用sequence 步骤 3 : 作为id插入到表中 create sequence hero_seq increment by 1 start with 1 maxvalue 9999999 创建了一个名字为hero_seq的序列 这个序列从1开始,每次增加1,最大值是9999999 select hero_seq.nextval from dual 获取hero_seq的下一个值 select hero_seq.currval from dual 获取hero_seq的当前值 insert into hero (id,name,hp,mp,damage,armor,speed) values(hero_seq.nextval,'炸弹人',450,200,45,3,300); 执行上述代码多次,再执行查询语句 select * from hero 可以看到后面再增加的数据的id就是自动增加的
HOW2J公众号,关注后实时获知最新的教程和优惠活动,谢谢。
![]()
提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
|