1

I have tried a php script like:

$res=mysql_query("SELECT TABLE_NAME 
                  FROM  information_schema.'TABLES' 
                  WHERE  UPDATE_TIME > NOW() - INTERVAL 2 DAY 
                  AND  ABLE_SCHEMA = 'mvgis_lewiscounty'");

which is not working.

Can anyone please guide me how should I proceed with this?

Fernando Carvalhosa
  • 1,102
  • 1
  • 15
  • 23

1 Answers1

3

There's no solution using INFORMATION_SCHEMA that works for both InnoDB and MyISAM.

The UPDATE_TIME is not updated for InnoDB tables. Update time for an InnoDB table is kind of subjective. Is it the time someone last did an UPDATE? Is it the time that update was COMMITed? Is it the time the change was flushed to the tablespace?

You'd be better off using a shell command like:

$ find /var/lib/mysql -name '*.ibd' -mtime -1

Another solution would be for all tables to have a trigger that updates a summary table with one row per table name, to record the latest INSERT/UPDATE/DELETE.

See also How can I tell when a MySQL table was last updated?

Community
  • 1
  • 1
Bill Karwin
  • 499,602
  • 82
  • 638
  • 795