使ç¨çº§èå é¤+触åå¨å¯ä»¥æå®ä½ çéæ±ã
ç¶è¡¨A å表B å¤ä»½è¡¨C
å½ä»¤å¦ä¸:
create table A
(
dept_ID number primary key,
dept_name varchar2(10)
);
create table B
(
no number primary key,
name varchar2(10),
dept_id number
);
ALTER TABLE WWJ.B ADD CONSTRAINT FK_B FOREIGN KEY (DEPT_ID) REFERENCES WWJ.A (DEPT_ID) ON DELETE CASCADE ENABLE VALIDATE;
CREATE OR REPLACE TRIGGER WWJ.TR_B_01
BEFORE DELETE
ON WWJ.B
REFERENCING NEW AS New OLD AS Old
FOR EACH ROW
BEGIN
INSERT INTO C VALUES(:old.no,:old.name,:old.dept_id);
END;
温馨提示:内容为网友见解,仅供参考