oracle 唯一键sequence、触发器
-- Create sequence
create sequence S_表名
minvalue 1
maxvalue 999999999999999999999999999
start with 1
increment by 1
cache 20;
CREATE OR REPLACE TRIGGER "触发器名"
BEFORE INSERT OR UPDATE ON 表名
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
BEGIN
IF INSERTING THEN
SELECT S_表名.NEXTVAL INTO :NEW.ID FROM DUAL; -- ID 表字段ID
END IF;
:NEW.UPDATE_TIME := TO_CHAR(SYSDATE,'YYYY-MM-DD HH24:MI:SS'); -- UPDATE_TIME 更新日期
END;
******未经允许,禁止转载 否则追究法律责任******