您当前的位置: 首页 >  ar

java持续实践

暂无认证

  • 2浏览

    0关注

    746博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

oracle varchar2序列的使用

java持续实践 发布时间:2018-11-14 16:48:41 ,浏览量:2

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 称之为伪记录变量, 记录着将要插入的变量值. 结果如图

关注
打赏
1658054974
查看更多评论
立即登录/注册

微信扫码登录

0.0661s