开始事务前的提交事务数:
mysql> SHOW GLOBAL STATUS LIKE '%com_comm%';
+---------------+-------+
| Variable_name | VALUE |
+---------------+-------+
| Com_commit | 109 |
+---------------+-------+
1 ROW IN SET (0.01 sec)
mysql> SHOW GLOBAL STATUS LIKE '%com_roll%';
+---------------------------+-------+
| Variable_name | VALUE |
+---------------------------+-------+
| Com_rollback| 1 |
| Com_rollback_to_savepoint | 0 |
+---------------------------+-------+
2 rows in set (0.01 sec)
如何开启一个事务:
mysql> start transaction;
Query OK, 0 rows affected (0.00 sec)
mysql> delete from t1 where id =2;
Query OK, 0 rows affected (0.00 sec)
mysql> insert into t1 values(2,'dskl');
Query OK, 1 row affected (0.03 sec)
mysql> select * from t1;
+----+------+
| id | name |
+----+------+
| 2 | dskl |
| 3 | kljk |
| 4 | dsljk |
| 5 |sjdljok |
+----+---------+
4 rows in set (0.01 sec)
mysql> delete from t1 where id=4;
Query OK, 1 row affected (0.00 sec)
mysql> commit;
Query OK, 0 rows affected (0.01 sec)
事务提交后的事务数:
mysql> show global status like '%com_comm%';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| Com_commit | 110 |
+---------------+-------+
1 row in set (0.01 sec)
mysql> show global status like '%com_roll%';
+----------------+-------+
| Variable_name| Value |
+----------------+------+
| Com_rollback | 1 |
| Com_rollback_to_savepoint | 0 |
+-----------------------+-------+
1rows in set (0.01 sec)