This is a discussion on Date of Last table update within the MySQL Database forums, part of the Database Forums category; Is there a way to query a particular table in a database and return the date that the database was ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
On Sun, 24 Feb 2008 18:21:00 -0500, Fred Atkinson wrote:
> Is there a way to query a particular table in a database and > return the date that the database was last updated? Kind of... Under most circumstances, MySQL can auto-update the first timestamp in a table as a "last changed" on the row, so you have all of those sorted DESCending and LIMIT 1 out of it. I don't know of an automagic function to do that across a whole database, though. -- 30. All bumbling conjurers, clumsy squires, no-talent bards, and cowardly thieves in the land will be preemptively put to death. My foes will surely give up and abandon their quest if they have no source of comic relief. --Peter Anspach's list of things to do as an Evil Overlord |
|
|||
|
> Is there a way to query a particular table in a database and
>return the date that the database was last updated? There is a way to query a particular table in a database and return the date/time that the *TABLE* was last updated. Query: SHOW TABLE STATUS LIKE 'tablename'; Look at the Update_time field returned. To get the database last update time, for reasonable definitions of what that means, I suppose you could get the update time of all the tables and take the latest one. Unless, of course, someone deleted a table recently, which this test wouldn't show. Also it wouldn't show modified views, triggers, etc. Another approach is: SELECT max(UPDATE_TIME) from INFORMATION_SCHEMA.TABLES WHERE INFORMATION_SCHEMA.TABLE_SCHEMA = '$databasename'; Which has the same weakness regarding deleted tables and things that aren't tables. |