今天工作的時候,用到了oracle數(shù)據(jù)庫建表,發(fā)現(xiàn)navicat中對于oracle的支持沒有那個主鍵自增的按鈕,網(wǎng)上查了下,就此記錄
建表:
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;
建觸發(fā)器
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;