Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
When a table has been updated
Message
De
14/03/2001 08:09:12
 
 
À
14/03/2001 06:47:54
Christian Cote
Les Logiciels Onoma Inc.
Longueuil, Québec, Canada
Information générale
Forum:
Oracle
Catégorie:
Autre
Divers
Thread ID:
00484762
Message ID:
00484777
Vues:
11
The time of the last update is *NOT* being maintained in the data dictionary.

So common practice is a timestamp column.

So on your table add a column lastupd of type date.

then use:
CREATE OR REPLACE TRIGGER mytable_audit_info 
 BEFORE INSERT OR UPDATE ON mytable"
  FOR EACH ROW 
  BEGIN 
   IF INSERTING THEN 
 :new.lastedit  := sysdate; 
  ELSIF UPDATING THEN ´
:new.lastedit  := sysdate; 
  END IF; 
 END; 
select max(lastupd) from mytable;

Gets you the last update.

2) If you have 8i then you can check using log miner. Not very useful in an application but good for DBA's to know here is a brief overview:

Oracle's Log Miner allows researching database transactions recorded in the online and archive redo logs. It can be a very useful tool to undo logical database corruption.

Preconditions:

Set initialization parameter UTL_FILE_DIR to the valid directory.
Run script dbmslmd.sql to create necessary packages.


--------------------------------------------------------------------------------

1. Build log miner dictionary (rebuild after database objects created or modified).

execute dbms_logmnr_d.build ( 'db_name_lm_dict.ora', '/export/home/oracle/admin/db_name/ufile );

2. To create list of redo / archive logs for analysis, execute:


BEGIN
dbms_logmnr.add_logfile(
options => dbms_logmnr.NEW,
logfilename => '/export/home/oracle/oradata/db_name/redo01.log'
);
dbms_logmnr.add_logfile(
options => dbms_logmnr.ADDFILE,
logfilename => '/export/home/oracle/oradata/db_name/redo02.log'
);
dbms_logmnr.start_logmnr(
dictfilename => '/export/home/oracle/admin/db_name/ufile/db_name_lm_dict.ora'
);
END;
/


3. Research stored transactions, using view V$LOGMNR_CONTENTS.


Example:
SELECT TO_CHAR(TIMESTAMP,'HH24:MI.SS') "Time",
USERNAME,
OPERATION,
SQL_REDO,
SQL_UNDO
FROM v$logmnr_contents
order by 1 desc
;


4. To finish:


EXECUTE dbms_logmnr.end_logmnr();


hope that helps!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform