创建现有的mysql触发器后,是否可以对其进行修改? [英] Can you modify an existing mysql trigger after it has been created?
问题描述
在mysql
中,我可以创建一个触发器,然后显示有关它的信息,如下所示:
In mysql
I can create a trigger, and then show information about it like this:
mysql> show triggers like 'fooTrigger';
此命令提供的输出看起来非常像select语句,并且一行显示了匹配的触发器.可以更新显示给我的行上的一列吗?
This command gives output that looks an awful lot like a select statement, with a row showing the matching trigger. Is it possible to update a column on the row it shows me?
例如,一列名为Statement
,它定义了激活触发器时发生的情况.是否可以更改fooTrigger
的Statement
字段,以便触发器执行其他操作?还是我需要drop
然后重新create
触发器?
For example, one column is named Statement
, and it defines what happens when the trigger is activated. Is it possible to change the Statement
field for fooTrigger
so the trigger does something different? Or do I need to drop
and re-create
the trigger?
推荐答案
从MySQL 5.5开始,您必须删除并重新创建触发器.
不删除触发器就无法更新Statement
列.
As of MySQL 5.5, you must drop and re-create the trigger.
It is not possible to update the Statement
column without dropping the trigger.
文档:创建触发器 您还可以使用INFORMATION_SCHEMA表访问有关触发器的信息:
You may also access information about triggers using the INFORMATION_SCHEMA tables:
SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
但是,由于这些表实际上是视图,因此不能在它们上使用UPDATE
.
与使用SHOW TRIGGERS相比,这是访问和处理信息的一种更方便的方法.
But, as these tables are actually views, you can't use UPDATE
on them.
It's just a more convenient way to access and manipulate the information than using SHOW TRIGGERS.
文档: INFORMATION_SCHEMA.TRIGGERS
这篇关于创建现有的mysql触发器后,是否可以对其进行修改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!