[英]Get the list of tables updated in last 24 hours of a database in MySQL with engine myisam or innodb
I have tried a php
script like: 我试过像这样的php
脚本:
$res=mysql_query("SELECT TABLE_NAME
FROM information_schema.'TABLES'
WHERE UPDATE_TIME > NOW() - INTERVAL 2 DAY
AND ABLE_SCHEMA = 'mvgis_lewiscounty'");
which is not working. 这是行不通的。
Can anyone please guide me how should I proceed with this? 任何人都可以指导我如何处理这个?
There's no solution using INFORMATION_SCHEMA that works for both InnoDB and MyISAM. 没有使用适用于InnoDB和MyISAM的INFORMATION_SCHEMA的解决方案。
The UPDATE_TIME
is not updated for InnoDB tables. InnoDB表的UPDATE_TIME
未更新。 Update time for an InnoDB table is kind of subjective. InnoDB表的更新时间是主观的。 Is it the time someone last did an UPDATE
? 是时候有人上次UPDATE
吗? Is it the time that update was COMMIT
ed? 是时候更新是COMMIT
ed了吗? Is it the time the change was flushed to the tablespace? 是将更改刷新到表空间的时间吗?
You'd be better off using a shell command like: 你最好使用shell命令,如:
$ find /var/lib/mysql -name '*.ibd' -mtime -1
Another solution would be for all tables to have a trigger that updates a summary table with one row per table name, to record the latest INSERT/UPDATE/DELETE. 另一种解决方案是让所有表都有一个触发器,用于更新每个表名一行的汇总表,以记录最新的INSERT / UPDATE / DELETE。
See also How can I tell when a MySQL table was last updated? 另请参见如何判断MySQL表的上次更新时间?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.