gpt4 book ai didi

mysql - 获取数据库的最后更新返回 null (mysql)

转载 作者:可可西里 更新时间:2023-11-01 07:21:53 26 4
gpt4 key购买 nike

我需要获取数据库上次更改(更新、修改等)的时间我执行以下查询,但它为所有表返回 null。有什么问题吗?

SELECT 
update_time
FROM
information_schema.tables
WHERE
table_schema = 'myschema'

最佳答案

作为 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.

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)

可能您正在使用 innodb 表并且您的 MySQL 版本早于文档中描述的版本。

关于mysql - 获取数据库的最后更新返回 null (mysql),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39870974/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com