Oracle数据库自增主键

create table TEAM_MAJOR_WORK
(
  pkid                NUMBER(7) not null,
  team_no            VARCHAR2(16) not null,
  ymonth              VARCHAR2(6) not null,
  iwork_plan             CLOB,
  iwork_desc             CLOB,
  iwork_result        CLOB,
  teamld_evluate      CLOB,
  depld_evluate      CLOB,
  cr_date             DATE default sysdate not null
);



--创建seq
create sequence TWORK_ID_SEQ start with 100000 increment by 1 maxvalue 999999;



--创建触发器
create or replace trigger TR_MAJOR_WORK
  before insert on TEAM_MAJOR_WORK
  for each row
  when (new.pkid is null)
begin
  select TWORK_ID_SEQ.NEXTVAL into:new.pkid from dual;
end;

--查询触发器
select * from all_triggers tr where tr.TRIGGER_NAME='TR_MAJOR_WORK';