Trigger to keep account unlock history

oracle

How can create trigger that will insert username and date to a table,when oracle user account unlocked to keep account lock history

Best Answer

You can write a database trigger like this:

CREATE OR REPLACE TRIGGER account_trigger
   BEFORE ALTER ON DATABASE
   WHEN ora_dict_obj_name = 'USER' 
BEGIN
   INSERT INTO LOG_TABLE (...) VALUES (...);
END;

Check this document to get more information

Maybe you can also use AUDIT ALTER USER; to get this information. See AUDIT