Database trigger in Container or Pluggable database multitenant

Use of database trigger in container or pluggable in Multitenant database

Database trigger used in Container or pluggable database

Create a database trigger event in Container database

Syntax:

--- For Container database syntax
CREATE OR REPLACE TRIGGER trigger_name
AFTER event_name ON DATABASE
BEGIN
  -- Do something.
  NULL;
END;
/

-- For pluggable database syntax
CREATE OR REPLACE TRIGGER trigger_name
AFTER event_name ON PLUGGABLE DATABASE
BEGIN
  -- Do something.
  NULL;
END;
/
-- For creating the container database trigger we need to connect Container database
CONN sys@cdb1 AS SYSDBA

-- Create trigger in CDB
CREATE OR REPLACE TRIGGER cdbtrigger
AFTER STARTUP ON DATABASE
BEGIN
  -- Do something.
  NULL;
END;
/

Create a database trigger event in Pluggable database

--- Connect the pluggable database
CONN sys@pdb1 AS SYSDBA

-- Create a pluggable trigger
CREATE OR REPLACE TRIGGER pdbtrigger_name
AFTER STARTUP ON PLUGGABLE DATABASE
BEGIN
  -- Do something.
  NULL;
END;
/

Events used in for database event both CDB or PDB

Following are the six database event triggers:

STARTUP: Fires when the database is opened.
SHUTDOWN: Fires when the database is shut down normally.
SERVERERROR: Fires when an Oracle error is raised.
LOGON: Fires when an Oracle database session begins.
LOGOFF: Fires when an Oracle database session terminates normally.
DB_ROLE_CHANGE: Fires when a standby database is changed to be the primary database or vice versa.

Leave a Reply