Ask the Expert

Row affected by last DML operation

How can I find the row of a table that was affected by the last DML operation?

    Requires Free Membership to View

The answer all depends on your version. One method that is version-independent is to add a new column to the table called DML_TIME. Then create a trigger which sets the DML_TIME column to SYSDATE on every INSERT, UPDATE or DELETE. Obviously, this method requires the trigger to be set up before the fact.

In Oracle 8i and higher, you can use Log Miner to mine the archived redo logs looking for this information.

In Oracle 10g, you can use the Flashback Versions Query to see the last DML against the table, provided that DML operation occurred less time ago than the number of seconds specified by the UNDO_RETENTION initialization parameter.

This was first published in July 2006

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

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: