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)

关注刘相兵的新浪微博

扫码加入微信Oracle小密圈,了解Oracle最新技术下载分享资源

Comments

  1. slowsoul says:

    刘大开始搞mysql啦?

Speak Your Mind

沪ICP备14014813号

沪公网安备 31010802001379号

TEL/電話+86 13764045638
Email service@parnassusdata.com
QQ 47079569