Skip to main content
← PL/SQL Topics

Triggers

Explain the categories of triggers: DML, DDL and database event

DML, DDL and Database Event Triggers

ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated

Triggers fire on DML on a table/view, on DDL such as CREATE/ALTER, or on database events like LOGON and SERVERERROR.

How it works

DML triggers fire BEFORE/AFTER INSERT, UPDATE or DELETE on a table (or INSTEAD OF on a view). DDL triggers fire on schema events — CREATE, ALTER, DROP, TRUNCATE — scoped ON SCHEMA or ON DATABASE, and can inspect ora_dict_obj_name and friends. Database event triggers fire on AFTER LOGON, BEFORE LOGOFF, AFTER STARTUP, BEFORE SHUTDOWN, AFTER SERVERERROR and AFTER SUSPEND. DDL and event triggers are common for auditing and for setting session context on logon.

How it works
CREATE OR REPLACE TRIGGER trg_audit_ddl
  AFTER DDL ON SCHEMA
BEGIN
  INSERT INTO ddl_audit (event, obj_type, obj_name, done_by, done_at)
  VALUES (ora_sysevent, ora_dict_obj_type, ora_dict_obj_name, USER, SYSTIMESTAMP);
END;
/

Related questions

GroundingGenerated

Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.

Have a follow-up, or a different question?

Continue in Ask Oracle AI