-- 两表双向增加触发器
delimiter //
-- DROP TRIGGER IF EXISTS admin_insert
CREATE TRIGGER admin_insert AFTER INSERT ON hotmine.admin FOR EACH ROW
BEGIN
IF NOT EXISTS ( SELECT * FROM hotmine_new.admin WHERE hotmine_new.admin.id = new.id ) THEN
INSERT INTO hotmine_new.admin ( hotmine_new.admin.`user`, hotmine_new.admin.`password` )
VALUES
(new.`user`,new.`password`);
END IF;
END//
delimiter;
delimiter //
CREATE TRIGGER admin_new_insert AFTER INSERT ON hotmine_new.admin FOR EACH ROW
BEGIN
IF NOT EXISTS ( SELECT * FROM hotmine.admin WHERE hotmine.admin.id = new.id ) THEN
INSERT INTO hotmine.admin ( hotmine.admin.`user`, hotmine.admin.`password` )
VALUES
(new.`user`,new.`password`);
END IF;
mysql的不同数据库的两表双向触发器
最新推荐文章于 2022-10-25 10:08:43 发布