我无法编辑MySQL触发器,必须删除它并创建一个新触发器,这是真的吗? [英] Is it true I can't edit a MySQL trigger, I have to drop it and create a new one?

查看:41
本文介绍了我无法编辑MySQL触发器,必须删除它并创建一个新触发器,这是真的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是真的我不能编辑MySQL触发器,必须删除它并创建一个新触发器吗?

Is it true I can't edit a MySQL trigger, I have to drop it and create a new one?

此外,作为触发器的一个新手,他们似乎容易引发错误"数据.例如,我可能希望在一种特定类型的更新查询之后触发触发器(将数据插入到另一个表中),而在其他情况下则不会.

Also, being a relative newcomer to triggers, it feels like they seem liable to causing 'erroneous' data. For example I might want a trigger to be fired (inserting data into another table) after one particular type of update query, but not others.

在此感谢所有收到的提示!

Any tips here gratefully received!

推荐答案

是的,确实是MySQL 5&的5.n和6.n版本. 6实现CREATE TRIGGERDROP TRIGGER,仅此而已.根据这堆Postgres文档,甚至没有CREATE TRIGGER在SQL 92中,因此您很幸运完全拥有TRIGGER:-)

Yes, it is true that versions 5.n and 6.n of MySQL 5 & 6 implement CREATE TRIGGER and DROP TRIGGER and nothing else. According to this hunk of Postgres documentation, there is not even CREATE TRIGGER in SQL 92, so consider yourself lucky to have TRIGGER at all :-)

Visual Studio MySQL插件文档具有:

要修改现有触发器,请双击要修改的触发器的节点,或右键单击该节点,然后从上下文菜单中选择更改触发器"命令.这两个命令都将打开"SQL编辑器".

To modify an existing trigger, double click on a node of the trigger you wish to modify, or right click on this node and choose the Alter Trigger command from a context menu. Either of the commands opens the SQL Editor.

...这似乎可以满足您的要求.我的猜测是这是GUI糖,在幕后您会得到一个DROP CREATE.

... which seems to do what you want. My guess is this is GUI sugar and behind the scenes you get a DROP CREATE.

就某些UPDATE而非其他触发器而言,SQL每张表恰好有一个UPDATE.在UPDATE触发器的开始处放置一个IF子句,以便仅在您认为适当时才执行您的逻辑-在某些UPDATE中正在执行的操作.

As far as a trigger for some UPDATEs and not others, SQL has exactly one UPDATE per table. Put an IF clause at the start of your UPDATE trigger so that your logic - whatever you are doing in some of your UPDATEs - is only executed when you think it is appropriate.

这篇关于我无法编辑MySQL触发器,必须删除它并创建一个新触发器,这是真的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆