当前位置:网站首页>MySQL project 7 Summary
MySQL project 7 Summary
2022-06-26 10:21:00 【m0_ sixty-one million nine hundred and sixty-one thousand eight】
Create and use triggers
trigger (TRIGGER) yes MySQL One of the database objects , from 5.0.2 Version starting support . This object is very similar to a function in a programming language , All need to be stated 、 Execution, etc . But the execution of the trigger is not called by the program , It's not started by hand , It's triggered by events 、 Activate to execute . It's kind of similar DOM In the event .
So why use database object triggers ? In the specific development project , The following examples are often encountered :
<1> Have the field student name in the student table , Total field students , Whenever you add a student message , The total number of students must be changed at the same time .
<2> There will also be abbreviations of students' names in the student list , Student address and other fields , When adding student information , It is often necessary to check the telephone 、 Whether the format of e-mail is correct .
The above example has such characteristics when it is completed with triggers , When the table changes , Do some processing automatically .MySQL It's triggering DELETE/UPDATE/INSERT Statement will automatically execute the set operation , other SQL Statement does not activate the trigger .
Create trigger
Use the help command to view the specific syntax :
CREATE
[DEFINER = { user | CURRENT_USER }]
TRIGGER trigger_name
trigger_time trigger_event
ON tbl_name FOR EACH ROW
trigger_body
In the syntax
trigger_name: Trigger name , Cannot be repeated with an existing trigger ;
trigger_time:{ BEFORE | AFTER }, Means to trigger before or after an event ;
trigger_event::{ INSERT |UPDATE | DELETE }, The specific event that triggers the trigger ;
tbl_name: The trigger acts on tbl_name On ;
View and delete triggers
Check triggers
SHOW TRIGGERS Statement view trigger information
SHOW TRIGGERS;
stay triggers See trigger information in table
Delete trigger
DROP TRIGGER Trigger Name ;
DROP TRIGGER trig_book ;
DROP TRIGGER trig_book2
边栏推荐
- Omni channel, multi scenario and cross platform, how does app analyze channel traffic with data
- When will JVM garbage collection enter the older generation
- The basis of C language grammar -- factoring by function applet
- Cento7.7 elk installation simple record
- TensorFlow动态分配显存
- Dialog centered
- 904. 水果成篮
- 1. sum of two numbers (leetcode topic)
- 微软 Edge 浏览器 IE 模式标签页出现卡死情况,已通过回滚更新修复
- String类intern()方法和字符串常量池
猜你喜欢

全渠道、多场景、跨平台,App如何借助数据分析渠道流量

Some problems to be considered when designing technical implementation scheme

Servlet learning notes II

3行3列整形二维数组,求对角之和

Extracting public fragments from thymeleaf

Under the double reduction, the amount of online education has plummeted. Share 12 interesting uses of webrtc

【Leetcode】76. 最小覆盖子串

904. 水果成篮

Develop current learning objectives and methods

Automated testing -- Introduction and use of pytest itself and third-party modules
随机推荐
Global and Chinese markets in hair conditioner 2022-2028: Research Report on technology, participants, trends, market size and share
Today's headline adaptation scheme code
MySQL第五章总结
创建对象的时候堆内存的分配
String类intern()方法和字符串常量池
How to change the QR code material color of wechat applet
[sans titre]
Crawler related articles collection: pyppeter, burpsuite
Glide's most common instructions
[binary search] 4 Find the median of two positive arrays
Global and Chinese market of recycled paper 2022-2028: Research Report on technology, participants, trends, market size and share
从tf 1.x到tf 2.6(遇到的就过来更新更新)
Blog article index Summary - wechat games
How to start the learning journey of webrtc native cross platform development?
創建對象的時候堆內存的分配
Battery historian analyzes battery consumption
Cmake / set command
【LeetCode】59. Spiral matrix II
mysql学习总结
exec系列函数(execl、execlp、execle、execv、execvp)使用