Q

Last updated row

Is there any way to find the last updated row in a specific table?

Is there any way to find the last updated row in a specific table?
The answer depends on the database version, which you did not specify. If you are using Oracle 8i or 9i, you can use LogMiner to mine your archived redo logs to determine which row was last updated in the table. In Oracle 10g, you can use a Flashback Versions Query to see the updates to the table.

The above methods can be used after the fact. Before the fact, you can add a column to the table called UPDATE_TIME defined with the DATE datatype. Then create a trigger on the table which sets the UPDATE_TIME column to SYSDATE on any INSERT or UPDATE command on the table. Determining the last updated row is as simple as querying for the row with the MAX(UPDATE_TIME) value. This method does require you to set up the column and trigger...

beforehand.

This was first published in July 2006

Dig deeper on Oracle database design and architecture

Pro+

Features

Enjoy the benefits of Pro+ membership, learn more and join.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

0 comments

Oldest 

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

-ADS BY GOOGLE

SearchDataManagement

SearchBusinessAnalytics

SearchSAP

SearchSQLServer

TheServerSide

SearchDataCenter

SearchContentManagement

SearchFinancialApplications

Close