Question

I have a program that retrieves data and stores it in a table each day, and then another program that queries that data to produce reports. The reports need to say when the data was last updated, so we know how old the information is.

It seems wasteful to add a column with the last update date to the table, since all the rows will have the same value. It also seems wasteful to create a table just to store one value.

What is the best solution for keeping track of the last time a table was updated?

Was it helpful?

Solution

My preferred way is to create a new "report" table to store the last time the target table is updated, and create a trigger to update the "report" table whenever there is change on the target table.

See this for more information on creating such trigger: http://www.techonthenet.com/oracle/triggers/after_update.php

OTHER TIPS

You Probably should add a column "LastModified" and save the datetime when its getting updated. This should be the best way to identify when your table was last updated.

This should help: http://docs.oracle.com/cd/B19306_01/server.102/b14237/statviews_2097.htm

ALL_TAB_MODIFICATIONS describes tables accessible to the current user that have been modified since the last time statistics were gathered on the tables. TIMESTAMP DATE Indicates the last time the table was modified

So:

select TIMESTAMP from ALL_TAB_MODIFICATIONS
where table_name = 'My_TABLE'
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top