Mysql:FAQ:A.5 Triggers
- A.5.1. Where can I find the documentation for MySQL 5.7 triggers?
- A.5.2. Is there a discussion forum for MySQL Triggers?
- A.5.3. Does MySQL 5.7 have statement-level or row-level triggers?
- A.5.4. Are there any default triggers?
- A.5.5. How are triggers managed in MySQL?
- A.5.6. Is there a way to view all triggers in a given database?
- A.5.7. Where are triggers stored?
- A.5.8. Can a trigger call a stored procedure?
- A.5.9. Can triggers access tables?
- A.5.10. Can a table have multiple triggers with the same trigger event and action time?
- A.5.11. Can triggers call an external application through a UDF?
- A.5.12. Is it possible for a trigger to update tables on a remote server?
- A.5.13. Do triggers work with replication?
- A.5.14. How are actions carried out through triggers on a master replicated to a slave?
A.5.1. |
Where can I find the documentation for MySQL 5.7 triggers? |
A.5.2. |
Is there a discussion forum for MySQL Triggers? |
Yes. It is available at https://forums.mysql.com/list.php?99. |
|
A.5.3. |
Does MySQL 5.7 have statement-level or row-level triggers? |
In MySQL 5.7, all triggers are |
|
A.5.4. |
Are there any default triggers? |
Not explicitly. MySQL does have specific special behavior for some |
|
A.5.5. |
How are triggers managed in MySQL? |
In MySQL 5.7, triggers can be created using the Information about triggers can be obtained by querying the |
|
A.5.6. |
Is there a way to view all triggers in a given database? |
Yes. You can obtain a listing of all triggers defined on database SELECT TRIGGER_NAME, EVENT_MANIPULATION, EVENT_OBJECT_TABLE, ACTION_STATEMENT
FROM INFORMATION_SCHEMA.TRIGGERS
WHERE TRIGGER_SCHEMA='
For more information about this table, see Section 24.29, “The INFORMATION_SCHEMA TRIGGERS Table”. You can also use the |
|
A.5.7. |
Where are triggers stored? |
Triggers are stored in |
|
A.5.8. |
Can a trigger call a stored procedure? |
Yes. |
|
A.5.9. |
Can triggers access tables? |
A trigger can access both old and new data in its own table. A trigger can also affect other tables, but it is not permitted to modify a table that is already being used (for reading or writing) by the statement that invoked the function or trigger. |
|
A.5.10. |
Can a table have multiple triggers with the same trigger event and action time? |
It is possible to define multiple triggers for a given table that have the same trigger event and action time. For example, you can have two |
|
A.5.11. |
Can triggers call an external application through a UDF? |
Yes. For example, a trigger could invoke the |
|
A.5.12. |
Is it possible for a trigger to update tables on a remote server? |
Yes. A table on a remote server could be updated using the |
|
A.5.13. |
Do triggers work with replication? |
Yes. However, the way in which they work depends whether you are using MySQL's “classic” statement-based or row-based replication format. When using statement-based replication, triggers on the slave are executed by statements that are executed on the master (and replicated to the slave). When using row-based replication, triggers are not executed on the slave due to statements that were run on the master and then replicated to the slave. Instead, when using row-based replication, the changes caused by executing the trigger on the master are applied on the slave. For more information, see Section 16.4.1.34, “Replication and Triggers”. |
|
A.5.14. |
How are actions carried out through triggers on a master replicated to a slave? |
Again, this depends on whether you are using statement-based or row-based replication. Statement-based replication. First, the triggers that exist on a master must be re-created on the slave server. Once this is done, the replication flow works as any other standard DML statement that participates in replication. For example, consider a table Row-based replication. When you use row-based replication, the changes caused by executing the trigger on the master are applied on the slave. However, the triggers themselves are not actually executed on the slave under row-based replication. This is because, if both the master and the slave applied the changes from the master and, in addition, the trigger causing these changes were applied on the slave, the changes would in effect be applied twice on the slave, leading to different data on the master and the slave. In most cases, the outcome is the same for both row-based and statement-based replication. However, if you use different triggers on the master and slave, you cannot use row-based replication. (This is because the row-based format replicates the changes made by triggers executing on the master to the slaves, rather than the statements that caused the triggers to execute, and the corresponding triggers on the slave are not executed.) Instead, any statements causing such triggers to be executed must be replicated using statement-based replication. For more information, see Section 16.4.1.34, “Replication and Triggers”. |
相关文章
- 什么是mysql的元数据呢?
- python读写mysql
- 让 MySQL 支持 emoji 存储
- 解决Navicat连接MySQL时“Client does not support authentication protocol requested by server; consider upgrading MySQL client”的问题
- MySQL 中 find_in_set() 函数的使用
- Mysql group_concat函数列转行,与行转列
- 基于Java+MySQL实现(Web)高校资源综合发布系统【100010343】
- Mysql Order By 字符串排序,mysql 字符串order by
- MySQL性能状态查看方式
- Linux数据库:MYSQL启用和查看二进制日志
- mysql数据库配置优化(占cpu过高问题)
- MYSQL 两日期之间的工作日(除去周六日,不考虑节假日)
- Mysql第四天 数据库设计
- 【3.2】【mysql基本实验】mysql GTID复制(基于空数据的配置)