本文介绍了MySql-保持最小行数的触发器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果要删除的语句的行数少于2000,我想撤消该操作:
I want to undo a delete statement if it brings the number of rows below 2000:
CREATE TRIGGER Trig1
AFTER DELETE ON Tab1
FOR EACH ROW
IF (SELECT COUNT(*) FROM Table1) < 2000
BEGIN
INSERT INTO Table1 (select * from old);
END;
END IF;
但是它不起作用.有人可以告诉我我在做什么错,应该怎么看?
But it is not working. Can someone tell me what am I doing wrong, and how this should look?
推荐答案
尝试,
INSERT INTO Table1
SELECT *
FROM old
记住点
- 由于您使用的是
*
,因此两个表上的表数和数据类型必须匹配
- the number of tables and data types must match on both tables since you are using
*
这篇关于MySql-保持最小行数的触发器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!