Is there anyway I can get the last updated time of a set of tables? By last updated time, I mean not only when the table's schema changed but when any of the rows changed or even when rows were created/deleted in the given set of tables.
I tried both SELECT * FROM information_schema.tables
and SHOW TABLE STATUS FROM myDb
and I only see the create_time
which is only when table was created.
I can alternatively create triggers like:
CREATE TRIGGER tbl1_delete AFTER DELETE ON tbl1
FOR EACH ROW
BEGIN
UPDATE table_updates SET update_time = now() WHERE table_name = tbl1
END
But, now I have to repeat this over and over for deletes, updates, creations and schema changes. And, I want to automate this for all my tables!
Best Answer
I got some interesting news for you. You cannot use information_schema.tables because it does not track changes to InnoDB tables.
The best way to find out when a table changed is to go to the OS and get the most recent timestamp of each table. Rather than plagiarize my own posts, here are my posts where I show you how to do this
Sep 25, 2014
: want to find out which databases are used in last 30 days or notJun 03, 2013
: Is there a way to find the least recently used tables in a schema?Apr 04, 2013
: How to check which tables in DB (MYSQL) updated in last 1 hour / last 1 minute?Dec 21, 2011
: Fastest way to check if InnoDB table has changedGive Them a Try !!!