Home >Database >Mysql Tutorial >oracle如何设置序列自动增长

oracle如何设置序列自动增长

WBOY
WBOYOriginal
2016-06-07 15:03:031179browse

欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入 oracle如何设置序列自动增长 droptable book; --创建表 createtable book( bookId varchar2(4) primarykey, name varchar2(20) ); --创建序列 createsequence book_seq start with 1 increment by 1

欢迎进入Oracle社区论坛,与200万技术人员互动交流 >>进入

  oracle如何设置序列自动增长

  droptable book;

  --创建表

  createtable book(

  bookId varchar2(4) primarykey,

  name varchar2(20)

  );

  --创建序列

  createsequence book_seq start with 1 increment by 1;

  --创建触发器

  createorreplacetrigger book_trigger

  before inserton book

  for each row

  begin

  select book_seq.nextval into :new.bookId from dual;

  end ;

  --添加数据

  insertinto book(name) values ('cc');

  insertinto book(name) values ('dd');

  commit;

oracle如何设置序列自动增长

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn