table: A 结构:
field1:a_id PRI
table: B 结构
field1: b_id PRI
field2: b_comment
并在用table B中
ALTER TABLE B
ADD CONSTRAINT `fx`
FOREIGN KEY (`b_id` )
REFERENCES A (`a_id` )
ON DELETE CASCADE
ON UPDATE NO ACTION;
和
DELIMITER $$
CREATE TRIGGER `del_b`
AFTER DELETE ON b
FOR EACH ROW
begin
set @x=852369;
end$$
然后插入值
insert into A(a_id)values(1);
insert into B(b_id,b_comment) values(1,2);
delete from A;
select @x;
但是最后面怎么就显示@x=NULL, 不是@x的值应该是852369的吗?
触发器没有运行?
要怎么样让触发器也运行呢?
帮顶,and 学习下
有触发器 就没有必要用外键