cmd 命令行模式下怎么为mysql创建触发器

个人比较喜欢用命令行来创建,很快的呀,用可视化界面创建的话一个不小心就要等很久,时间就是金钱!

上命令:

delimiter //
CREATE TRIGGER countadd AFTER INSERT ON user
FOR EACH ROW
BEGIN
UPDATE usernum set count = count+1;
END
//

cmd 命令行模式下怎么为mysql创建触发器_第1张图片

退出验证:(不退出的话每条语句末尾要加//才算结束,还没解决)

mysql> use test;
Database changed
mysql> select * from usernum;
+----+-------+
| id | count |
+----+-------+
|  1 |     1 |
+----+-------+
1 row in set (0.00 sec)

mysql> insert into user (`user`) values ('test');
Query OK, 1 row affected (0.12 sec)

mysql> select * from usernum;
+----+-------+
| id | count |
+----+-------+
|  1 |     2 |
+----+-------+
1 row in set (0.00 sec)

 

cmd 命令行模式下怎么为mysql创建触发器_第2张图片

你可能感兴趣的:(从MySQl坑中爬起来)