有什么办法可以查看ALTER TABLE执行后的情况吗? -MySQL
同样的方式SHOW CREATE TABLE tblname;返回之前执行的内容,是否有办法查看 ALTER TABLE 查询的 SQL? 请帮忙?
In the same way SHOW CREATE TABLE tblname; brings back what was previously executed, is there anyway to view the SQL of an ALTER TABLE query?
Please help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
需要澄清一点:
show create table
实际上并不“恢复之前执行的内容”。它只是向您显示将从头开始创建表的 DDL。该表可能已创建并更改了多次,但show create table
反映了表的当前状态。至于查找最近在表上运行的任何
alter table
语句,最好的选择是二进制日志。首先检查是否启用了二进制日志:
如果是,则找到相关时间段的二进制日志,使用mysqlbinlog将其转换为SQL,然后grep相关表名找到
alter table
您正在寻找的声明。One small clarification:
show create table
does not actually "bring back what was previously executed". It just shows you the DDL that would create the table from scratch. The table may have been created and then altered many times, butshow create table
reflects the current state of the table.As for finding any
alter table
statements that ran on the table recently, the best bet is the binary log.First check to see if binary logging is enabled:
If it is, find the binary log for the relevant time period, use mysqlbinlog to convert it to SQL, then grep for the relevant table name to find the
alter table
statement you are looking for.工具:
手动:
首先检查是否启用了二进制日志记录:
然后,
转到 test.file 查看 alter 语句。
Tools:
Manual:
First check to see if binary logging is enabled:
Then,
Go to test.file to see the alter statements.
如果您的 MySQL 实例开启了日志记录,您可以查看日志。这将是最好的选择。
如果您的系统打开了历史记录,您可以从同一系统启动客户端备份并尝试向上箭头。您也许可以在那里看到该命令。
如果您认识运行该命令的用户,并且他们碰巧直接从命令行运行该命令,则相同的历史记录技巧可能会起作用。
If your MySQL instance has logging turned on, you can view the logs. This would be the best option.
If your system has history turned on, you can start a client back up from the same system and try the up arrow. You might be able to see the command there.
If you know the user that ran the command and they happened to run it directly from a command line, the same history trick might work.