Oracle 主键设置自增策略
时间:2021-07-01 10:21:17
帮助过:8人阅读
创建自增序列
CREATE SEQUENCE seq_interface_info
INCREMENT BY 1
START WITH 1 --从1开始
NOMAXVALUE
--不设最大值
NOCYCLE
--不循环
NOCACHE;
-- 创建表interface_info的触发器
CREATE TRIGGER interface_info_trigger
BEFORE INSERT --
ON interface_info
FOR EACH ROW
BEGIN
SELECT seq_interface_info.nextval
INTO:new.api_id
FROM dual;
END;
--创建表interface_release的触发器
CREATE TRIGGER interface_release_trigger
BEFORE INSERT --
ON interface_release
FOR EACH ROW
BEGIN
SELECT seq_interface_info.nextval
INTO:new.pub_id
FROM dual;
END;
Oracle 主键设置自增策略
标签:seq sel api row nbsp class acl inter ace