By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,680 Members | 2,139 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,680 IT Pros & Developers. It's quick & easy.

last update

P: n/a
Ike
Is there a way in mysql to discern when the last date/time a field, row, or
table was been updated or inserted? Thanks, ike
Jul 23 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
>Is there a way in mysql to discern when the last date/time a field, row, or
table was been updated or inserted? Thanks, ike


Maybe, for rows. A timestamp field (well, the first one) is
automatically set to the current time when the row is modified, or
when the row is created, UNLESS it is explicitly set to another
time other than null. So if you handle it properly, you've got a
row-last-modified-time field. Insert it as null (or leave it out
of the field list), and don't update it at all. It will be maintained
for you. But it is easy to fake it by explicitly setting that field
to something else.

Table modification times are available with SHOW TABLE STATUS.
These may be more recent than expected due to things that might not
be considered modifications, like OPTIMIZE TABLE, which doesn't
really change any of the data.

There's no place to store a modification time for every field, and
no automatic way of updating them, unless you use triggers (available
in MySQL 5.0). Then you could have an automatically-maintained
update log (field FOO of table BAR changed from %s to %s at <time>
by <user>) in another table used to track the changes.

Gordon L. Burditt
Jul 23 '05 #2

P: n/a
Ike

"Gordon Burditt" <go****@hammy.burditt.org> wrote in message
news:11*************@corp.supernews.com...
Is there a way in mysql to discern when the last date/time a field, row, ortable was been updated or inserted? Thanks, ike


Maybe, for rows. A timestamp field (well, the first one) is
automatically set to the current time when the row is modified, or
when the row is created, UNLESS it is explicitly set to another
time other than null. So if you handle it properly, you've got a
row-last-modified-time field. Insert it as null (or leave it out
of the field list), and don't update it at all. It will be maintained
for you. But it is easy to fake it by explicitly setting that field
to something else.


How would you access that value Gordon? Thanks, Ike
Jul 23 '05 #3

P: n/a
Ike

"Ike" <rx*@hotmail.com> wrote in message
news:6Z*****************@newsread2.news.pas.earthl ink.net...

How would you access that value Gordon? Thanks, Ike


Whoops, my mistake - I assumed MySQL kept a value for that outside your own
table. I see now that you meant adding a TIMESTAMP field to the table.
Thanks again, Ike
Jul 23 '05 #4

P: n/a
>> >Is there a way in mysql to discern when the last date/time a field, row,
or
>table was been updated or inserted? Thanks, ike


Maybe, for rows. A timestamp field (well, the first one) is
automatically set to the current time when the row is modified, or
when the row is created, UNLESS it is explicitly set to another
time other than null. So if you handle it properly, you've got a
row-last-modified-time field. Insert it as null (or leave it out
of the field list), and don't update it at all. It will be maintained
for you. But it is easy to fake it by explicitly setting that field
to something else.


How would you access that value Gordon? Thanks, Ike


With a SELECT, just like any other field.

YOU have to put that field in the table; it's not a magic field
with a magic name that's always there.

Gordon L. Burditt
Jul 23 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.