CREATE TABLE example(
ID Number(4) NOT NULL PRIMARY KEY,
NAME VARCHAR(25),
PHONE VARCHAR(10),
ADDRESS VARCHAR(50));
CREATE SEQUENCE emp_sequence
INCREMENT BY 1 -- 每次加几个
START WITH 1 -- 从1开始计数
NOMAXVALUE -- 不设置最大值
NOCYCLE -- 一直累加,不循环
NOCACHE -- 不建缓冲区
CREATE TRIGGER "触发器名称" BEFORE
INSERT ON example FOR EACH ROW WHEN (new.id is null)
begin
select emp_sequence.nextval into:new.id from dual;
end;