Date of Last table update

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 ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-24-2008
Fred Atkinson
 
Posts: n/a
Default Date of Last table update

Is there a way to query a particular table in a database and
return the date that the database was last updated?

Regards,



Fred
Reply With Quote
  #2 (permalink)  
Old 02-25-2008
Peter H. Coffin
 
Posts: n/a
Default Re: Date of Last table update

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
Reply With Quote
  #3 (permalink)  
Old 02-25-2008
Gordon Burditt
 
Posts: n/a
Default Re: Date of Last table update

> 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.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 09:07 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0