对于MyISAM引擎
SELECT update_time
FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema = 'yourDatabaseName'
AND table_name = 'yourTableName'
但是对于innodb的有时候uptime是null值
我个人想到的办法是通过指定log相关参数,如general_log_file和SET global general_log = 1;
通过日志的shell分析找到相关表的信息如:
query_words=$(cat mysql_general.log | tr -s [:space:] \\n | tr -c -d '[a-zA-Z0-9][:space:][_\-]' | egrep -v '[0-9]' | sort | uniq)
table_names=$(mysql -uroot -ptest -Dmeta -e"show tables;" | sort | uniq)
comm -12 <(echo $table_names) <(echo $query_words)