查看 MySQL 临时表 - 不在会话中
我当前正在运行一个脚本,但没想到会花费这么长时间来运行,该脚本正在修改临时表。
我知道临时表仅存在于当前会话中,但是无论如何可以从会话外部查看它们保存的数据吗?
原因是我想知道我的脚本将继续运行多长时间,如果我可以看到临时数据,那么我就能弄清楚。
I currently have a script running and didn't think it would take so long to run, the script is modifying a temporary table.
I know that temporary tables only exist for the current session, but is there anyway to see the data they hold from outside the session?
Reason is that I want to know how long my script is going to keep running for, if I could see the temporary data then I'd be able to figure it out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
恐怕没有简单的方法可以做到这一点。
临时表将存储在 mysqld 指定的临时目录中(通常为 /tmp),您将看到一组类似于以下内容的表:
这是一组正常的 MyISAM 表,定义(按上面的顺序)结构、数据和索引。
这非常糟糕,但我怀疑您可以将这些表复制到您的
test
模式中,对表进行修复,然后查看其内容。如果您可以通过临时表的大小来衡量进程,那么这很可能是分析正在发生的情况的更简单的方法。
There's no easy way of doing this I'm afraid.
Temporary tables will be stored in your mysqld's designated temp directory (usually /tmp) and you'll see a set of tables something like:
That's a normal set of MyISAM tables defining (in order above) structure, data and index.
This is horribly hacky but I suspect you could copy these tables out into say your
test
schema, run a repair on the table and then view it's contents.If you can gauge the process by the size of the temp table then that could well be a simpler way of analysing what's going on.
不可能,但可以(但是),
日志里程碑(消息、完成百分比、已处理的行数)
写入临时文件,并使用
tail -f log_file
进行监控Is not possible, you can (however),
log milestone (message, % of completion, number rows processed)
into a temporary file, and use the
tail -f log_file
to monitor在 MySQL 5.7 中,添加了新的 INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO: http://dev.mysql.com/doc/refman/5.7/en/innodb-information-schema-temp-table-info.html。
否则,Percona XtraDB 已经拥有此功能一段时间了:http://venublog。 com/2010/02/03/show-temporary-tables/
In MySQL 5.7 a new INFORMATION_SCHEMA.INNODB_TEMP_TABLE_INFO has been added: http://dev.mysql.com/doc/refman/5.7/en/innodb-information-schema-temp-table-info.html.
Otherwise Percona XtraDB has had this feature for a little while: http://venublog.com/2010/02/03/show-temporary-tables/