Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Automatic Schema Change Tracking in Oracle Using Database-Level DDL Trigger (Incident Prevention Approach)

SURESH THULASI RAMFeb 14 2026 — edited Feb 14 2026

I recently saw an incident (in LinkedIn Post) where a small database change — renaming a column from user_id to userId — caused an entire analytics pipeline to stop working because downstream systems were not informed.
This highlights a simple truth: even a small structural database change can silently break multiple applications that depend on that data.
A practical enterprise solution is to implement a database schema change tracking mechanism.
Whenever someone makes a structural change (CREATE, ALTER, DROP, RENAME), the database automatically records:
• Who made the change
• When it was made
• Which object was affected
• The exact SQL statement executed
This works like a black-box recorder for the database, helping teams quickly identify the reason when a pipeline suddenly fails.
Below is a simple Oracle implementation.
Step 1 — Create schema change audit table
CREATE TABLE schema_change_log (
id NUMBER GENERATED ALWAYS AS IDENTITY,
event_time TIMESTAMP,
username VARCHAR2(100),
object_owner VARCHAR2(100),
object_name VARCHAR2(100),
object_type VARCHAR2(50),
ddl_operation VARCHAR2(50),
sql_text CLOB
);
Step 2 — Create DDL trigger to capture schema changes
CREATE OR REPLACE TRIGGER trg_log_schema_changes
AFTER DDL ON DATABASE
DECLARE
v_sql ORA_NAME_LIST_T;
v_stmt CLOB;
n NUMBER;
BEGIN
n := ora_sql_txt(v_sql);

FOR i IN 1..n LOOP
v_stmt := v_stmt || v_sql(i);
END LOOP;

INSERT INTO schema_change_log (
event_time,
username,
object_owner,
object_name,
object_type,
ddl_operation,
sql_text
)
VALUES (
SYSTIMESTAMP,
SYS_CONTEXT('USERENV','SESSION_USER'),
ORA_DICT_OBJ_OWNER,
ORA_DICT_OBJ_NAME,
ORA_DICT_OBJ_TYPE,
ORA_SYSEVENT,
v_stmt
);
END;
/
Step 3 — Test example
ALTER TABLE employees RENAME COLUMN user_id TO userId;

SELECT event_time, username, object_name, ddl_operation, sql_text
FROM schema_change_log
ORDER BY event_time DESC;
Step 4 — Monitoring view for quick RCA
CREATE OR REPLACE VIEW vw_recent_schema_changes AS
SELECT *
FROM schema_change_log
WHERE event_time > SYSTIMESTAMP - INTERVAL '1' DAY;
Step 5 — Enterprise enhancements
Alert notification
UTL_MAIL.send(
sender => 'db-alert@company.com',
recipients => 'data-team@company.com',
subject => 'Schema Change Detected',
message => 'A schema change has occurred. Check schema_change_log.'
);
Approval enforcement pattern
IF ORA_SYSEVENT = 'ALTER' THEN
RAISE_APPLICATION_ERROR(-20001,'Schema change requires approval');
END IF;
Reliable data platforms are not built only by strong pipelines — they are built by making every structural change visible, traceable, and governed.

Comments