HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMinor

How to get a last DML operation in Oracle 10g-11g

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
last11g10goperationgetdmlhoworacle

Problem

I can get a number of last INSERT's/UPDATE's/DELETE's from SQL%ROWCOUNT var. Also there exists a way to get a last DML time of each row.

But is there a way to get a last DML operation performed on a table - INSERT/UPDATE/DELETE?

Solution

With this query you will see your last DML event by loonking on last change , most recent date is the last operation

SELECT TABLE_OWNER, 
   TABLE_NAME, 
   INSERTS,
   UPDATES,
   DELETES,
   TIMESTAMP AS `LAST_CHANGE`
FROM  ALL_TAB_MODIFICATIONS
WHERE TO_CHAR(TIMESTAMP,'DD/MM/YYYY') = TO_CHAR(sysdate,'DD/MM/YYYY') 
ORDER BY LAST_CHANGE DESC;


But the only way to use it its separating the DML events in differents querys or adding three differents last_change per dml event.
In any case you tell me your doubts

Code Snippets

SELECT TABLE_OWNER, 
   TABLE_NAME, 
   INSERTS,
   UPDATES,
   DELETES,
   TIMESTAMP AS `LAST_CHANGE`
FROM  ALL_TAB_MODIFICATIONS
WHERE TO_CHAR(TIMESTAMP,'DD/MM/YYYY') = TO_CHAR(sysdate,'DD/MM/YYYY') 
ORDER BY LAST_CHANGE DESC;

Context

StackExchange Database Administrators Q#115062, answer score: 5

Revisions (0)

No revisions yet.