题解 | #构造一个触发器audit_log#
构造一个触发器audit_log
http://www.nowcoder.com/practice/7e920bb2e1e74c4e83750f5c16033e2e
两种方法
方法一:牛客编译器能正常通过
CREATE TRIGGER audit_log after insert
ON employees_test
FOR EACH ROW
BEGIN
INSERT INTO audit VALUES(NEW.ID, NEW.NAME);
END;
方法二:牛客编译器不能正常通过,本地MySQL能正常通过
CREATE TRIGGER audit_log after insert
ON employees_test
FOR EACH ROW
BEGIN
INSERT INTO audit
SET action = 'insert',
EMP_no = NEW.ID,
NAME = NEW.NAME,
changedat = NOW();
END;
SQL练习 文章被收录于专栏
已完成牛客的SQL练习。接下来是算法的练习