I need to get last time of changes (update, modification etc) to the database I do the following query, but it returns null for all tables. What can be wrong?
我需要上次更改(更新,修改等)到数据库我执行以下查询,但它为所有表返回null。有什么不对?
SELECT
update_time
FROM
information_schema.tables
WHERE
table_schema = 'myschema'
1 个解决方案
#1
5
As MySQL documentation on information_schema.tables says (emphasis added):
正如关于information_schema.tables的MySQL文档所述(强调添加):
Beginning with MySQL 5.7.2, UPDATE_TIME displays a timestamp value for the last UPDATE, INSERT, or DELETE performed on InnoDB tables that are not partitioned. Previously, UPDATE_TIME displayed a NULL value for InnoDB tables. For MVCC, the timestamp value reflects the COMMIT time, which is considered the last update time. Timestamps are not persisted when the server is restarted or when the table is evicted from the InnoDB data dictionary cache.
从MySQL 5.7.2开始,UPDATE_TIME显示在未分区的InnoDB表上执行的最后一次UPDATE,INSERT或DELETE的时间戳值。以前,UPDATE_TIME为InnoDB表显示NULL值。对于MVCC,时间戳值反映COMMIT时间,该时间被视为最后更新时间。重新启动服务器或从InnoDB数据字典缓存中逐出表时,时间戳不会保留。
The UPDATE_TIME column also shows this information for partitioned InnoDB tables in MySQL 5.7.8 and later. Previously this column was always NULL for such tables. (Bug #17299181, Bug #69990)
UPDATE_TIME列还显示MySQL 5.7.8及更高版本中分区的InnoDB表的此信息。以前,此列对于此类表始终为NULL。 (Bug#17299181,Bug#69990)
Probably you are using innodb tables and your MySQL version is earlier than described in the documentation.
可能你正在使用innodb表,你的MySQL版本早于文档中描述的。
#1
5
As MySQL documentation on information_schema.tables says (emphasis added):
正如关于information_schema.tables的MySQL文档所述(强调添加):
Beginning with MySQL 5.7.2, UPDATE_TIME displays a timestamp value for the last UPDATE, INSERT, or DELETE performed on InnoDB tables that are not partitioned. Previously, UPDATE_TIME displayed a NULL value for InnoDB tables. For MVCC, the timestamp value reflects the COMMIT time, which is considered the last update time. Timestamps are not persisted when the server is restarted or when the table is evicted from the InnoDB data dictionary cache.
从MySQL 5.7.2开始,UPDATE_TIME显示在未分区的InnoDB表上执行的最后一次UPDATE,INSERT或DELETE的时间戳值。以前,UPDATE_TIME为InnoDB表显示NULL值。对于MVCC,时间戳值反映COMMIT时间,该时间被视为最后更新时间。重新启动服务器或从InnoDB数据字典缓存中逐出表时,时间戳不会保留。
The UPDATE_TIME column also shows this information for partitioned InnoDB tables in MySQL 5.7.8 and later. Previously this column was always NULL for such tables. (Bug #17299181, Bug #69990)
UPDATE_TIME列还显示MySQL 5.7.8及更高版本中分区的InnoDB表的此信息。以前,此列对于此类表始终为NULL。 (Bug#17299181,Bug#69990)
Probably you are using innodb tables and your MySQL version is earlier than described in the documentation.
可能你正在使用innodb表,你的MySQL版本早于文档中描述的。