In-built database “information_schema” not logging

2019-09-19 19:39发布

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条回答
够拽才男人
2楼-- · 2019-09-19 20:13

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.

查看更多
登录 后发表回答