我运行下面的 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
我运行下面的 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
如果 Command 列显示“Sleep”,则该会话中没有运行 SQL 查询。客户端可能已运行您显示的 UPDATE 查询,但该查询已完成。它仅在执行时显示在进程列表中。
您可以检查performance_schema.events_statements_history_long
表以查看在每个会话中运行的先前查询。将该表加入进程列表需要一些工作。见https://dev.mysql.com/doc/mysql-perfschema-excerpt/8.0/en/performance-schema-statement-tables.html