MySQL 如何获得当前会话的TRX_ID 事务ID

 

 

mysql>  show variables like '%commit%';
+--------------------------------+-------+
| Variable_name                  | Value |
+--------------------------------+-------+
| autocommit                     | OFF   |
| innodb_commit_concurrency      | 0     |
| innodb_flush_log_at_trx_commit | 1     |
+--------------------------------+-------+
3 rows in set (0.00 sec)

mysql> select version();
+-------------------------+
| version()               |
+-------------------------+
| 5.5.40-0ubuntu0.14.04.1 |
+-------------------------+
1 row in set (0.00 sec)


mysql>  insert into tv values(1);
Query OK, 1 row affected (0.00 sec)

mysql>  insert into tv values(1);
Query OK, 1 row affected (0.01 sec)

mysql> SELECT TRX_ID FROM INFORMATION_SCHEMA.INNODB_TRX  WHERE TRX_MYSQL_THREAD_ID = CONNECTION_ID();
+--------+
| TRX_ID |
+--------+
| 9648   |
+--------+
1 row in set (0.00 sec)

Comments

  1. slowsoul says

    刘大开始搞mysql啦?

Comment

*

沪ICP备14014813号-2

沪公网安备 31010802001379号