创建自增长字段

1.创建SEQUENCE
-- Create sequence
create sequence R_RADARSARFORECAST_AUTOINC
minvalue 1
maxvalue 999999999999999999999999999
start with 1
increment by 1
nocache;
2.创建表
-- Create table
create table R_RADARSARFORECAST
(
  OID        NUMBER not null,
  SARTYPE    NVARCHAR2(1),
  RVALUE     FLOAT,
  RTYPE      NVARCHAR2(1),
  CREATETIME DATE,
  CODE       VARCHAR2(16),
  RNAME      VARCHAR2(50)
)
tablespace SFBD
  pctfree 10
  initrans 1
  maxtrans 255
  storage
  (
    initial 1M
    minextents 1
    maxextents unlimited
  );
3. 创建触发器
create or replace trigger TRI_RADARFORECAST_AUTOINC
   before insert on gdsf2.r_radarsarforecast
   for each row
declare
  -- local variables here
begin
   select R_RADARSARFORECAST_AUTOINC.nextval into:new.oid from dual;
end TRI_RADARFORECAST_AUTOINC;

你可能感兴趣的:(自增长)