In-built database “information_schema” not logging the last update time of a table in user created database

落花浮王杯 提交于 2019-12-12 04:46:36

问题


The tables table of the in-built database information_schema does not log the activities of the tables in user created databases as the fields table_schema and table_name lacks the values of the user created databases and table names respectively, disallowing me to run the SQL query

SELECT update_time 
FROM information_schema.tables 
WHERE table_schema='my_db' and table_name='my_table';
-- For table named 'my_table' in database 'my_db'

for retrieving last update time (or changed time) of a table in database (i.e. the last time when data in a specific table is updated, deleted or inserted) for deciding whether a backup is needed or not.

Can anyone please help me solve this problem of logging activities in database and explain me the reason behind it?

Thanks in advance.


回答1:


Apparently your tables are InnoDB, and you are using MariaDB version below 10.2.

What you have encountered is an old MySQL bug (or rather an absence of feature, as it was envisioned by the InnoDB team). It has been fixed in the latest stable InnoDB, which is included into MariaDB 10.2.

For MyISAM tables it should work in previous versions too.



来源:https://stackoverflow.com/questions/44162115/in-built-database-information-schema-not-logging-the-last-update-time-of-a-tab

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!