As per the requirement i need to capture the the last DML operations in tables in complete schema while searching i have noticed two resources
Resource 1 https://dba.stackexchange.com/questions/115062/how-to-get-a-last-dml-operation-in-oracle-10g-11g
Resource 2 https://oraclebykkbakshi.blogspot.com/2018/04/check-date-and-time-of-last-dml-done-on.html
Among the above i have tried using both the queries
Query1 - DBA_TAB_MODIFICATIONS
SELECT TABLE_OWNER,TABLE_NAME,INSERTS,UPDATES,DELETES,TIMESTAMP AS LAST_CHANGE
FROM DBA_TAB_MODIFICATIONS
WHERE TO_CHAR(TIMESTAMP,'DD.MM.YYYY') = TO_CHAR(sysdate,'DD.MM.YYYY')
and table_owner='SCHEMA_NAME'
and table_name in ('MY LIST OF TABLES')
Result - it fetched only the results which had fetched only few tables
Query2 - is very slow
select max(ora_rowscn),SCN_TO_TIMESTAMP(max(ora_rowscn)) FROM 'MY LIST OF TABLES'
If i check for any tables using query 2 i am getting the below error
Error Query 2
ORA-08181: specified number is not a valid system change number
ORA-06512: at "SYS.SCN_TO_TIMESTAMP", line 1
08181. 00000 - "specified number is not a valid system change number"
*Cause: supplied scn was beyond the bounds of a valid scn.
*Action: use a valid scn.
how to check all the tables in a single go ,since if i need to use query 2 ,how do i list out multiple tables in a single query ?
so my question is which is the correct query to search for ?
or any other better ways to look for ,any suggestions ?
Upon suggestion i have tried running the query
SELECT *
FROM 'TABLE_NAME' t
MINUS
SELECT *
FROM 'TABLE_NAME'
AS OF timestamp systimestamp - interval '1' day t
AS OF timestamp systimestamp - interval '1' day t - what is the value i have to use here ?
The following recommendations will help you in your SQL tuning process.
You'll find 3 sections below:
CREATE INDEX dba_modifications_idx_table_owner_table_name ON DBA_TAB_MODIFICATIONS (table_owner,table_name);
SELECT
DBA_TAB_MODIFICATIONS.TABLE_OWNER,
DBA_TAB_MODIFICATIONS.TABLE_NAME,
DBA_TAB_MODIFICATIONS.INSERTS,
DBA_TAB_MODIFICATIONS.UPDATES,
DBA_TAB_MODIFICATIONS.DELETES,
DBA_TAB_MODIFICATIONS.TIMESTAMP AS LAST_CHANGE
FROM
DBA_TAB_MODIFICATIONS
WHERE
TO_CHAR(DBA_TAB_MODIFICATIONS.TIMESTAMP, 'DD.MM.YYYY') = TO_CHAR(DBA_TAB_MODIFICATIONS.sysdate, 'DD.MM.YYYY')
AND DBA_TAB_MODIFICATIONS.table_owner = 'SCHEMA_NAME'
AND DBA_TAB_MODIFICATIONS.table_name IN (
'MY LIST OF TABLES'
)