Ddl Trigger

  • Uploaded by: Rahul Gupta
  • 0
  • 0
  • May 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Ddl Trigger as PDF for free.

More details

  • Words: 198
  • Pages: 2
How to create a DDL Trigger By: Rahul Gupta [email protected] http://onlineerpdba.blogspot.com/

Note: Very good for monitoring all the DDL at your database

SQL > Conn / as sysdba SQL > CREATE TABLE perfstat.STATS$DDL_LOG ( USER_NAME VARCHAR2(25 BYTE), DDL_DATE DATE, DDL_TYPE VARCHAR2(25 BYTE), OBJECT_TYPE VARCHAR2(25 BYTE), OWNER VARCHAR2(25 BYTE), OBJECT_NAME VARCHAR2(30 BYTE), TERMINAL_NAME VARCHAR2(40 BYTE), IP_ADDRESS VARCHAR2(30 BYTE) ); Table created.

SQL > grant all on perfstat.STATS$DDL_LOG to apps; Grant succeeded.

SQL > conn apps Enter password: Connected. SQL > create synonym DDL_LOG for perfstat.STATS$DDL_LOG; Synonym created.

SQL > conn / as sysdba Connected.

SQL >

CREATE OR REPLACE TRIGGER DDLTrigger AFTER DDL ON DATABASE DECLARE v_terminal_name varchar2(40); v_ip_address varchar2(40); BEGIN SELECT SYS_CONTEXT ('USERENV', 'TERMINAL') INTO v_terminal_name FROM DUAL; SELECT SYS_CONTEXT ('USERENV', 'IP_ADDRESS') INTO v_ip_address FROM DUAL; insert into perfstat.stats$ddl_log ( user_name, ddl_date, ddl_type, object_type, owner, object_name, terminal_name , ip_address ) VALUES ( ora_login_user, sysdate, ora_sysevent, ora_dict_obj_type, ora_dict_obj_owner, ora_dict_obj_name, v_terminal_name, v_ip_address ); END; / Trigger created.

SQL > /*

conn apps Enter password: Connected.

Sample Output */

SQL > USER_NAME ---------APPS APPS

> select * from DDL_LOG; DDL_DATE --------16-JUN-08 16-JUN-08

DDL_TYPE ---------CREATE DROP

OBJECT_TYPE --------------TABLE TABLE

OWNER -------APPS APPS

OBJECT_NAME -------------------MOHIT MOHIT

TERMINAL_NAME -------------------LGDBA LGDBA

IP_ADDRESS --------------10.102.120.118 10.102.120.118

==================================================================================================================

Related Documents

Ddl Trigger
May 2020 11
Ddl
November 2019 17
Ddl
May 2020 17
Trigger
November 2019 31
Trigger
November 2019 30
Trigger
June 2020 22

More Documents from ""