当前位置:网站首页>Whether MySQL has triggers
Whether MySQL has triggers
2022-06-21 20:07:00 【Yisu cloud】
mysql Is there a trigger
This article mainly introduces “mysql Is there a trigger ” Knowledge about , Xiaobian shows you the operation process through practical cases , The operation method is simple and fast , Practical , Hope this article “mysql Is there a trigger ” The article can help you solve problems .
mysql There are triggers .MySQL Triggers are a set of SQL Statement set , yes MySQL A powerful tool for managing data in , It is mainly used to protect the data in the table .MySQL Three triggers are supported :1、INSERT trigger , Is in INSERT Triggers that respond before or after statement execution ;2、UPDATE trigger , Is in UPDATE Triggers that respond before or after statement execution ;3、DELETE trigger , Is in DELETE Triggers that respond before or after statement execution .
The operating environment of this tutorial :windows7 System 、mysql8 edition 、Dell G3 The computer .
mysql There are triggers .
MySQL The trigger is the same as the stored procedure , Are embedded in MySQL One of the procedures in , Is a set of... Stored in the database directory SQL Statement set , yes MySQL A powerful tool for managing data in . The difference is that executing stored procedures uses CALL Statement to call , And trigger execution doesn't need to use CALL Statement to call , It doesn't need to be started by hand , It is triggered by related operations on the data table 、 Activate to execute . For example, when it comes to student Table operation (INSERT,DELETE or UPDATE) It will be activated to execute .
Triggers are closely related to data tables , It is mainly used to protect the data in the table . Especially when there are multiple tables that are related to each other , Triggers enable different tables to maintain data consistency .
stay MySQL in , Only execute INSERT、UPDATE and DELETE The trigger can only be activated during operation , Other SQL Statement does not activate the trigger .
Advantages and disadvantages of flip flops
The advantages of triggers are as follows :
Trigger execution is automatic , Execute immediately after making corresponding modifications to the data of the trigger related table .
Triggers can be implemented better than FOREIGN KEY constraint 、CHECK Constrain more complex checks and actions .
Triggers enable cascading changes to table data , To a certain extent, it ensures the integrity of the data .
The disadvantages of triggers are as follows :
Business logic implemented with triggers is difficult to locate when problems arise , Especially when multiple triggers are involved , It will make later maintenance difficult .
Extensive use of triggers can easily cause code structure to be disrupted , Increases the complexity of the program ,
If the amount of data to be changed is large , The execution efficiency of triggers will be very low .
MySQL There are three kinds of triggers :
MySQL There are three types of triggers supported :INSERT trigger 、UPDATE Trigger and DELETE trigger .
1) INSERT trigger
stay INSERT Triggers that respond before or after statement execution .
2) UPDATE trigger
stay UPDATE Triggers that respond before or after statement execution .
3) DELETE trigger
stay DELETE Triggers that respond before or after statement execution .
About “mysql Is there a trigger ” That's all for , Thanks for reading . If you want to know more about the industry , You can pay attention to the Yisu cloud industry information channel , Xiaobian will update different knowledge points for you every day .
边栏推荐
猜你喜欢

如何在Chrome浏览器中临时修改SameSite=None和Secure

A simple architecture design logic | acquisition technology

Uniapp applet opens the map and selects the location demo effect wx Chooselocation

RecycleView懒加载失效问题(二)

Tensorflow 2: use neural network to classify and compare fashion MNIST

How to use devaxpress WPF to create the first MVVM application in winui?

JVM内存结构

Clustering, dimension reduction and measurement techniques for machine learning

Source code analysis of ArrayList

Introduction to setting program icon in QT
随机推荐
Forwarding to remind metamask how to deal with the potential private key disclosure of the expansion program
Recycleview lazy load failure (II)
How to set the picture background to transparent
【时序预测完整教程】以气温预测为例说明论文组成及PyTorch代码管道构建
Model evaluation and selection of machine learning
[high frequency interview questions] difficulty 1.5/5, classic "prefix and + two points" application questions
uniapp小程序打开地图选择位置demo效果wx.chooseLocation(整理)
Using fastjson to deserialize simplegrantedauthority in the security framework
RPA财务流程自动化 | 浦发集团携手云扩科技加速财务数字化运营
[complete course of time series prediction] take temperature prediction as an example to illustrate the composition of the paper and the construction of pytorch code pipeline
研报精选 | 麦肯锡《中国数字创新未来》趋势解读
Dynamic programming [II] (linear DP)
zabbix6.0+timescaledb+企业微信告警
1156 Sexy Primes
谷粒学院P40~43
谷歌浏览器80版本以后,如何处理出现的问题SameSite跨域问题
Security框架中使用FastJson反序列化SimpleGrantedAuthority
Tableapi & SQL and example module of Flink
NSIS 运行bat的方法汇总
1157 Anniversary