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 !

Patrick KearnsRank #1,413 · 1.2K reputationPosted Nov 2, 2025, 6:12 AM EST
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.Sandhiya PriyaRank #26 · 43.2K reputationPosted Nov 6, 2025, 1:46 AM EST
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 TABLE audit_log ( action VARCHAR2(10), table_name VARCHAR2(100), old_values CLOB, new_values CLOB, action_timestamp DATE, user_id VARCHAR2(100) );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:
CREATE OR REPLACE TRIGGER audit_trigger_update AFTER UPDATE ON your_table_name FOR EACH ROW BEGIN INSERT INTO audit_log (action, table_name, old_values, new_values, action_timestamp, user_id) VALUES ( 'UPDATE', 'your_table_name', 'OLD: ' || :OLD.column1 || ', ' || :OLD.column2, 'NEW: ' || :NEW.column1 || ', ' || :NEW.column2, SYSDATE, USER ); END;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.