我使用的是idea连接oracle数据库
create table "N_AS_RECORD"
(
"AS_ID" number(12) not null
constraint SEQ_N_AS_RECORD_AS_ID primary key,
"PT_ID" number(12),
"AS_CREATOR" number(12),
"AS_DP" number(12),
"AS_TYPE" char(2),
"AS_UNIT_NAME" CHAR(10),
"AS_TIME" date,
"AS_MODEL_ID" number(12)
)
/
-- 创建序列
-- SEQ_N_AS_RECORD_AS_ID 序列名
create sequence SEQ_N_AS_RECORD_AS_ID
increment by 1 -- 每次递增1
start with 1 -- 从1开始
nomaxvalue -- 没有最大值
minvalue 1 -- 最小值=1
NOCYCLE; -- 不循环
/
-- 创建触发器
-- "trig" 触发器名
-- N_AS_RECORD 表名
-- SEQ_N_AS_RECORD_AS_ID 序列名
-- AS_ID 要自增的字段名
create or replace trigger "trig"
before insert on N_AS_RECORD
for each row
begin
select SEQ_N_AS_RECORD_AS_ID.nextval into :new.AS_ID from dual;
end;