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)


Posted

in

by

Tags:

Comments

One response to “MySQL 如何获得当前会话的TRX_ID 事务ID”

  1. slowsoul Avatar
    slowsoul

    刘大开始搞mysql啦?

Leave a Reply

Your email address will not be published. Required fields are marked *