您当前的位置: 首页 >  ar

oracle varchar2序列的使用

发布时间:2018-11-14 16:48:41 ,浏览量:5

create table book( bookId varchar2(4) primary key, name varchar2(20) ); --创建序列 create sequence book_seq start with 1 increment by 1 NOMAXvalue 
NOCYCLE 
NOCACHE; --创建触发器 create or replace trigger book_trigger
before insert on book for each row begin select book_seq.nextval into :new.bookId from dual; end ; --添加数据 insert into book(name) values ('cc'); insert into book(name) values ('dd'); commit; select * from book; 

注意 :new.bookId要为book表中的id的名称 . :new称之为伪记录变量, 记录着将要插入的变量值. 结果如图

关注
打赏
1688896170
查看更多评论

暂无认证

  • 5浏览

    0关注

    115984博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文
立即登录/注册

微信扫码登录

0.0935s