今天在生产上准备把新表加入到库中,运维在建表等反面给了一些案例和建议和大家共勉
1 标准TIGGER写法参考如下
CREATE OR REPLACE TRIGGER "QRPAY"."APP_INFO_ID_TRG" BEFORE INSERT OR UPDATE ON app_info
FOR EACH ROW
DECLARE
v_newVal NUMBER(12) := 0;
v_incval NUMBER(12) := 0;
BEGIN
IF INSERTING AND :new.id IS NULL THEN
SELECT app_info_id_seq.NEXTVAL INTO v_newVal FROM DUAL;
-- If this is the first time this table have been inserted into (sequence == 1)
IF v_newVal = 1 THEN
--get the max indentity value from the table
SELECT NVL(max(id),0) INTO v_newVal FROM app_info;
v_newVal := v_newVal + 1;
--set the sequence to that value
LOOP
EXIT WHEN v_incval>=v_newVal;
SELECT app_info_id_seq.nextval INTO v_incval FROM dual;
END LOOP;
END IF;
--used to emulate LAST_INSERT_ID()
--mysql_utilities.identity := v_newVal;
-- assign the valu