oracle 自增主键

前端之家收集整理的这篇文章主要介绍了oracle 自增主键前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
  1. create table AppInfo
  2. (
  3. fid number primary key,fappID VARCHAR2(32) not null,fappSecret VARCHAR2(32) not null
  4. );

2.创建自增序列


  1. CREATE SEQUENCE voucherdb_sequence
  2. INCREMENT BY 1 -- 每次加几个
  3. START WITH 1 -- 1开始计数
  4. NOMAXVALUE -- 不设置最大值
  5. NOCYCLE -- 一直累加,不循环
  6. NOCACHE -- 不建缓冲区

3,设置触发器
  1. create trigger AppInfo_trig before
  2. insert on AppInfo for each row when (new.fid is null)
  3. begin
  4. select voucherdb_sequence.nextval into:new.fid from dual;
  5. end;

猜你在找的Oracle相关文章