标签:end stat div efault innodb enum new last aqi
mysql> CREATE TABLE emploee ( -> name CHAR(64) NOT NULL, -> email CHAR(64), -> password CHAR(64), -> PRIMARY KEY (email) -> ) ENGINE = InnoDB; Query OK, 0 rows affected (0.01 sec) mysql> CREATE TABLE log ( id INT AUTO_INCREMENT, email CHAR(64), message TEXT, -> status ENUM(‘FAIL‘,‘OK‘)DEFAULT ‘FAIL‘, -> ts TIMESTAMP, -> PRIMARY KEY(id) -> )ENGINE=MyISAM; Query OK, 0 rows affected (0.00 sec) -> delimiter $$ -> CREATE TRIGGER tr_employee_insert_before BEFORE INSERT ON emploee -> FOR EACH ROW -> BEGIN -> INSERT INTO log(email,message) -> VALUES (NEW.email,CONCAT(‘Adding employee‘,NEW.name)); -> SET @LAST_INSERT_ID = LAST_INSERT_ID(); -> END $$ mysql> CREATE TRIGGER tr_employee_insert_after AFTER INSERT ON emploee -> FOR EACH ROW -> UPDATE log SET status = ‘OK‘ WHERE id = @LAST_INSERT_ID;
标签:end stat div efault innodb enum new last aqi
原文地址:https://www.cnblogs.com/betterquan/p/11751602.html