【问题标题】:how to get the SQL statement based on the process ID?如何根据进程ID获取SQL语句?
【发布时间】:2020-05-05 13:05:28
【问题描述】:

我运行下面的 SQL,然后运行 ​​SELECT * FROM information_schema.processlist 以获取 SQL 语句“update new_table set c1=c1+12”,但是列 info 为空, 那么如何获取语句呢?

use   test_db;
start transaction;
update new_table set c1=c1+12

【问题讨论】:

  • 你需要提交事务

标签: mysql processlist


【解决方案1】:

如果命令列显示“睡眠”,则该会话中没有运行 SQL 查询。客户端可能已运行您显示的 UPDATE 查询,但该查询已完成。它仅在执行时显示在进程列表中。

您可以检查performance_schema.events_statements_history_long 表以查看在每个会话中运行的先前查询。将该表加入进程列表需要一些工作。见https://dev.mysql.com/doc/mysql-perfschema-excerpt/8.0/en/performance-schema-statement-tables.html

【讨论】:

    猜你喜欢
    • 2014-08-31
    • 1970-01-01
    • 1970-01-01
    • 2022-01-26
    • 2015-10-09
    • 1970-01-01
    • 2010-12-25
    • 1970-01-01
    相关资源
    最近更新 更多