Hello,
I am using asp.net and database as oracle.
I want to record log for audit purpose, whenever any CRUD action perform either from front end or directly from database. Like what was new record and what was old record against it, everything with dattetime.
If it is TRIGGGERS in Oracle then how to use to each table ?
Any help or recommendations are very helpful.
Thanks in advance !
Sandhiya PriyaPosted Nov 6, 2025, 6:46 AM
You can use Oracle Triggers to automatically capture changes (INSERT, UPDATE, DELETE) on each table and log them into an audit table.
Here's a simple outline for setting up triggers on each table:
Create an Audit Table: This table will store the audit logs, including details like the action (INSERT/UPDATE/DELETE), old and new values, and a timestamp.
Example:
Create a Trigger for Each Table: Create triggers for each table that you want to monitor. The trigger will capture the old and new values for each operation.
Example trigger for an UPDATE:
Repeat for INSERT and DELETE:
For INSERT, you capture the new values only.
For DELETE, you capture the old values.
Generalize with PL/SQL: If you need to apply this across multiple tables, you can write a more dynamic solution using PL/SQL to loop through all tables.
Note: You’ll want to handle performance considerations, as logging each CRUD operation on every table could impact performance. Also, be cautious about logging sensitive information.
Patrick KearnsPosted Nov 2, 2025, 11:12 AM
Use triggers and store just the columns that change, you can use JSON payloads for each change.
This stores one row per change, with old/new snapshots. Using
CLOB+IS JSONkeeps it compatible across versions.