当前位置:网站首页>【mysql学习笔记29】触发器
【mysql学习笔记29】触发器
2022-07-06 07:13:00 【yqs_281876918】
创建
CREATE TRIGGER trigger_name
BEFORE/AFTER INSERT/UPDATE/DELETE
ON tb_name FOR EACH ROW – 行级触发器
BEGIN
trigger_statement;
END;
查看
SHOW TRIGGERS;
删除
DROP TRIGGER [schema_name.]trigger_name; --没有指定schema_name默认为当前数据库
案例
create trigger tb_user_insert_trigger after insert on tb_user for each row
begin
insert into tb_logs(id,operation,operate_time,operate_id,operate_params)
values(null,'insert',now(),new.id,concat('插入的数据内容为:',new.content));
end;
create trigger tb_user_insert_trigger after update on tb_user for each row
begin
insert into tb_logs(id,operation,operate_time,operate_id,operate_params)
values(null,'update',now(),new.id,concat('更新前数据:',old.content));
end;
边栏推荐
- What does UDP attack mean? UDP attack prevention measures
- Bloom taxonomy
- #systemverilog# 可綜合模型的結構總結
- Refer to how customer push e-commerce does content operation
- 中青看点阅读新闻
- C - Inheritance - hidden method
- ORACLE列转行--某字段按指定分隔符转多行
- You deserve this high-value open-source third-party Netease cloud music player
- L'auteur est mort? Ai utilise l'art pour conquérir l'humanité
- leetcode59. 螺旋矩阵 II(中等)
猜你喜欢
Cookie Technology & session Technology & ServletContext object
CDN acceleration and cracking anti-theft chain function
数据仓库建设思维导图
变量的命名规则十二条
呆错图床系统源码图片CDN加速与破解防盗链功能
leetcode704. 二分查找(查找某个元素,简单,不同写法)
NFT on fingertips | evaluate ambire on G2, and have the opportunity to obtain limited edition collections
A brief introduction of reverseme in misc in the world of attack and defense
Wechat official account infinite callback authorization system source code, launched in the whole network
Development of entity developer database application
随机推荐
开源的网易云音乐API项目都是怎么实现的?
微信公众号无限回调授权系统源码 全网首发
RichView TRVStyle 模板样式的设置与使用
Embed UE4 program into QT interface display
MPLS experiment
leetcode704. Binary search (find an element, simple, different writing)
Bio model realizes multi person chat
Raspberry pie serial port login and SSH login methods
Three methods of adding color to latex text
What does UDP attack mean? UDP attack prevention measures
配置树莓派接入网络
leetcode841. 钥匙和房间(中等)
Short video, more and more boring?
You deserve this high-value open-source third-party Netease cloud music player
Setting and using richview trvstyle template style
WPF之MVVM
Supervisor usage document
Proteus -- Serial Communication parity flag mode
Wechat official account infinite callback authorization system source code, launched in the whole network
OpenJudge NOI 2.1 1661:Bomb Game