需求 新建日志表
用于记录老师表的数据化情况 起个名字 teacher_log
需要的列 id operation msg
建老师日志表
CREATE TABLE teacher_log(
id INT PRIMARY KEY AUTO_INCREMENT,
operation VARCHAR(11) NOT NULL,
msg VARCHAR(200) NOT NULL
);
定义添加触发器
如果往老师表 teacher 中添加了数据 自动的做一条记录到老师日志表 teacher_log 中
DELIMITER !
CREATE TRIGGER teacher_insert_triger
AFTER INSERT ON teacher FOR EACH ROW
BEGIN
INSERT INTO teacher_log VALUES(NULL,'INSERT',CONCAT(new.id,'-',new.name,'-',new.skill));
END !
标签:INSERT,20240918,log,id,实操,new,NULL,teacher,102020
From: https://blog.51cto.com/u_13137233/12044000