今天工作的时候,用到了oracle数据库建表,发现navicat中对于oracle的支持没有那个主键自增的按钮,网上查了下,就此记录
建表:
CREATE TABLE "API_ATTENDANCE"
( "ID" NUMBER(10,0) NOT NULL ENABLE,
"ATTENDANCE_DATE" DATE,
"ATTENDANCE_TIME" DATE,
"ATTENDANCE_URL" VARCHAR2(2000),
"USER_ID" NUMBER(10,0),
PRIMARY KEY ("ID"));
建序列
CREATE SEQUENCE API_ATTENDANCE _sequence
MAXVALUE 9999999999999
MINVALUE 1
START WITH 1
INCREMENT BY 1
CACHE 20;
建触发器
create trigger API_ATTENDANCE _trig before
insert on API_ATTENDANCE for each row when (new.id is null)
begin
select API_ATTENDANCE _sequence .nextval into:new.id from dual;
end;