当前位置:网站首页>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
边栏推荐
- Blog article index summary -- Software Engineering
- MySQL第十四次作业--电子商城项目
- MySQL第五章总结
- Global and Chinese markets in hair conditioner 2022-2028: Research Report on technology, participants, trends, market size and share
- 【LeetCode】59. Spiral matrix II
- 創建對象的時候堆內存的分配
- 动态库连接 - 符号冲突 - 全局符号介入
- 如何更改微信小程序二维码物料颜色
- A list of common methods for customizing paint and canvas of view
- 定制拦截器
猜你喜欢

【Leetcode】76. 最小覆盖子串

微软 Edge 浏览器 IE 模式标签页出现卡死情况,已通过回滚更新修复

MySQL第十一作业-视图的应用

Test instructions - common interface protocol analysis

【LeetCode】59. 螺旋矩阵 II

Internationalization configuration

DBSCAN

Some problems to be considered when designing technical implementation scheme

Little red book - Summary of internal sales spike project

创建对象的时候堆内存的分配
随机推荐
TensorFlow动态分配显存
P1296 whispers of cows (quick row + binary search)
About multi table query of MySQL
Nested recyclerview in nestedscrollview automatically slides to the bottom after switching
Poj3682 king arthur's birthday celebration (probability)
Global and Chinese market of cryogenic bulk tanks 2022-2028: Research Report on technology, participants, trends, market size and share
1. 两数之和(LeetCode题目)
方法区里面有什么——class文件、class文件常量池、运行时常量池
leetCode-链表的中间结点
Leetcode intermediate node of linked list
Establishment of smart dialogue platform for wechat official account
Learning and understanding of thread pool (with code examples)
Renesas electronics launched a complete intelligent sensor solution for Internet of things applications
Introduction to libmagic
MySQL第十次作业-视图
What is LSP
mysql学习总结
1. sum of two numbers (leetcode topic)
How to find and install the dependent libraries of Debian system
Hcia-dhcp experiment