DBA Hub

📋Steps in this guide1/2

Multitenant : Database Triggers on Pluggable Databases (PDBs) in Oracle 12c Release 1 (12.1)

With the introduction of the multitenant option, database event triggers can be created in the scope of the CDB or PDB.

oracle 12cconfigurationintermediate
by OracleDba
13 views
1

Trigger Scope

To create a trigger on a database event in a CDB requires a connection to the CDB as a common user with the system privilege. To create a trigger on a database event in a PDB requires a connection to the PDB as either a common or local user with the system privilege in the context of the PDB. The and clauses are functionally equivalent within the PDB, but some events require the clause explicitly. Some database event triggers are also available at schema level within the CDB or PDB. Functionally, these are unchanged by the multitenant option.

Code/Command (click line numbers to comment):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
CONN sys@cdb1 AS SYSDBA

CREATE OR REPLACE TRIGGER cdb1_after_startup_trg
AFTER STARTUP ON DATABASE
BEGIN
  -- Do something.
  NULL;
END;
/

CONN sys@pdb1 AS SYSDBA

CREATE OR REPLACE TRIGGER pdb1_after_startup_trg
AFTER STARTUP ON PLUGGABLE DATABASE
BEGIN
  -- Do something.
  NULL;
END;
/

CREATE OR REPLACE TRIGGER pdb1_after_startup_trg
AFTER STARTUP ON DATABASE
BEGIN
  -- Do something.
  NULL;
END;
/

CONN sys@cdb1 AS SYSDBA

CREATE OR REPLACE TRIGGER cdb1_after_logon_trg
AFTER LOGON ON flows_files.SCHEMA
BEGIN
  -- Do something.
  NULL;
END;
/

CONN sys@pdb1 AS SYSDBA

CREATE OR REPLACE TRIGGER cdb1_after_logon_trg
AFTER LOGON ON test.SCHEMA
BEGIN
  -- Do something.
  NULL;
END;
/
2

Event Availability

The following database events are available at both the CDB and PDB level. - : Trigger fires after the CDB or PDB opens. - : Trigger fires before the CDB shuts down or before the PDB closes. - : Trigger fires when a server error message is logged and it is safe to fire error triggers. Available at or level. - : Trigger fires when a client logs into the CDB or PDB. Available at or level. - : Trigger fires when a client logs out of the CDB or PDB. Available at or level. - : Trigger fires when a server error causes a transaction to be suspended. Available at or level. - : Trigger fires before the command executes. Available at or level. - : Trigger fires after the command executes. Available at or level. The following database event is only available at the CDB level. - : Fires when the database role switches from primary to standby or from standby to primary in a Data Guard configuration. The following database events are only available at the PDB level and require the clause explicitly. Using the clause results in an error. - : After a clone operation, the trigger fires in the new PDB and then the trigger is deleted. If the trigger fails, the clone operation fails. - : Before an unplug operation, the trigger fires in the PDB and then the trigger is deleted. If the trigger fails, the unplug operation fails. For more information see: Hope this helps. Regards Tim...

Comments (0)

Please to add comments

No comments yet. Be the first to comment!