Oracle 触发器的使用小结
时间:2020-10-01 15:47:30|栏目:Oracle|点击: 次
--建递增序列
CREATE SEQUENCE LZEAM_SP_LOOP_EQ_SEQ MINVALUE 1 INCREMENT BY 1 START WITH 1
测试:
SELECT LZEAM_SP_LOOP_EQ_SEQ.NEXTVAL FROM DUAL
--建触发器
CREATE OR REPLACE TRIGGER LZEAM.LZEAM_SP_LOOP_EQ_TRIGGER BEFORE INSERT ON SP_LOOP_EQ FOR EACH ROW BEGIN SELECT LZEAM.LZEAM_SP_LOOP_EQ_SEQ.NEXTVAL INTO :NEW.LOOP_EQ_CODE FROM DUAL; END;
--查触发器
SELECT * FROM USER_TRIGGERS;
/**启/禁用触发器*/
ALTER TABLE SP_LOOP_EQ DISABLE ALL TRIGGERS ALTER TABLE SP_LOOP_EQ ENABLE ALL TRIGGERS
CREATE SEQUENCE LZEAM_SP_LOOP_EQ_SEQ MINVALUE 1 INCREMENT BY 1 START WITH 1
测试:
SELECT LZEAM_SP_LOOP_EQ_SEQ.NEXTVAL FROM DUAL
--建触发器
CREATE OR REPLACE TRIGGER LZEAM.LZEAM_SP_LOOP_EQ_TRIGGER BEFORE INSERT ON SP_LOOP_EQ FOR EACH ROW BEGIN SELECT LZEAM.LZEAM_SP_LOOP_EQ_SEQ.NEXTVAL INTO :NEW.LOOP_EQ_CODE FROM DUAL; END;
--查触发器
SELECT * FROM USER_TRIGGERS;
/**启/禁用触发器*/
ALTER TABLE SP_LOOP_EQ DISABLE ALL TRIGGERS ALTER TABLE SP_LOOP_EQ ENABLE ALL TRIGGERS
上一篇:Oracle 函数大全
栏 目:Oracle
下一篇:PL/SQL登录Oracle数据库报错ORA-12154:TNS:无法解析指定的连接标识符已解决(本地未安装Oracle需要连接服务器上的)
本文标题:Oracle 触发器的使用小结
本文地址:http://www.codeinn.net/misctech/5775.html