mysql Navicat Lite触发器 有两个表 一个为temp 一个为 date 我想要在temp中按id删除一条记录时把 这条记录插入到date表中 在Navicat Lite中定义触发器 希望大虾指教一下不胜感激 在线等 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 mysql> create table `temp` ( -> id int primary key, -> col int -> );Query OK, 0 rows affected (0.27 sec)mysql> create table `date` -> ( -> id int, -> col int -> );Query OK, 0 rows affected (0.13 sec)mysql> delimiter //mysql>mysql> create trigger trg_temp_bd before delete ON `temp` -> FOR EACH ROW BEGIN -> INSERT INTO `date` values(old.id,old.col); -> END; -> -> //Query OK, 0 rows affected (0.11 sec)mysql> delimiter ;mysql> insert into `temp` values -> (1,100), -> (2,200), -> (3,300), -> (4,400);Query OK, 4 rows affected (0.16 sec)Records: 4 Duplicates: 0 Warnings: 0mysql> select * from `temp` ;+----+------+| id | col |+----+------+| 1 | 100 || 2 | 200 || 3 | 300 || 4 | 400 |+----+------+4 rows in set (0.00 sec)mysql> select * from `date`;Empty set (0.03 sec)mysql>mysql> delete from `temp` where id=2 or id=3;Query OK, 2 rows affected (0.11 sec)mysql> select * from `temp` ;+----+------+| id | col |+----+------+| 1 | 100 || 4 | 400 |+----+------+2 rows in set (0.00 sec)mysql> select * from `date`;+------+------+| id | col |+------+------+| 2 | 200 || 3 | 300 |+------+------+2 rows in set (0.00 sec)mysql> 问一个 SQL 语句 数据库新增时间字段问题 关于Mysql 时间的问题 求助mysql下中文问题 mysql读取一条记录大小 在事务性表 和非事务性表的区别是什么? 如何设置mysql启动后 默认的数据库为我自己建立的一个数据库,而不用每次都得use XXX;多谢啦 关于 Binary 的问题? Mysql导出为Excel文件 php读mysql数据时的奇怪问题 N多人都没搞定的SQL语句 mysql Navicat Lite触发器
-> id int primary key,
-> col int
-> );
Query OK, 0 rows affected (0.27 sec)mysql> create table `date`
-> (
-> id int,
-> col int
-> );
Query OK, 0 rows affected (0.13 sec)mysql> delimiter //
mysql>
mysql> create trigger trg_temp_bd before delete ON `temp`
-> FOR EACH ROW BEGIN
-> INSERT INTO `date` values(old.id,old.col);
-> END;
->
-> //
Query OK, 0 rows affected (0.11 sec)mysql> delimiter ;
mysql> insert into `temp` values
-> (1,100),
-> (2,200),
-> (3,300),
-> (4,400);
Query OK, 4 rows affected (0.16 sec)
Records: 4 Duplicates: 0 Warnings: 0mysql> select * from `temp` ;
+----+------+
| id | col |
+----+------+
| 1 | 100 |
| 2 | 200 |
| 3 | 300 |
| 4 | 400 |
+----+------+
4 rows in set (0.00 sec)mysql> select * from `date`;
Empty set (0.03 sec)mysql>
mysql> delete from `temp` where id=2 or id=3;
Query OK, 2 rows affected (0.11 sec)mysql> select * from `temp` ;
+----+------+
| id | col |
+----+------+
| 1 | 100 |
| 4 | 400 |
+----+------+
2 rows in set (0.00 sec)mysql> select * from `date`;
+------+------+
| id | col |
+------+------+
| 2 | 200 |
| 3 | 300 |
+------+------+
2 rows in set (0.00 sec)mysql>