SlideShare a Scribd company logo
=======================================================
DDL logging: In Oracle 11g&12c
================================================================
There was no direct option available to log the DDL action in the previous releases.
1) From 11gr2 /12cR1, you can now log the DDL action into xml and log files.
2) This will be very useful to know when the drop or create command was executed
and by who.
3) The ENABLE_DDL_LOGGING initiation parameter can be set at the Database or
Session levels.
4) When this parameter is enabled, all DDL commands are logged in an xml and a
log file under the $ORACLE_BASE/diag/rdbms/DBNAME/log|ddl location.
5) An xml file contains information, such as DDL command, IP address, timestamp
etc.
6) It helps to identify User/Table dropped (or) DDL statement is triggered.
To enable DDL logging
SQL> ALTER SYSTEM|SESSION SET ENABLE_DDL_LOGGING=TRUE;
Note: When ENABLE_DDL_LOGGING is set to true, the following DDL statements are
written to the alert log:
ALTER/CREATE/DROP/TRUNCATE CLUSTER
ALTER/CREATE/DROP FUNCTION
ALTER/CREATE/DROP INDEX
ALTER/CREATE/DROP OUTLINE
ALTER/CREATE/DROP PACKAGE
ALTER/CREATE/DROP PACKAGE BODY
ALTER/CREATE/DROP PROCEDURE
ALTER/CREATE/DROP PROFILE
ALTER/CREATE/DROP SEQUENCE
CREATE/DROP SYNONYM
ALTER/CREATE/DROP/RENAME/TRUNCATE TABLE
ALTER/CREATE/DROP TRIGGER
ALTER/CREATE/DROP TYPE
ALTER/CREATE/DROP TYPE BODY
DROP USER
ALTER/CREATE/DROP VIEW
Following is the example of DDL logging:
======================================
-bash-4.1$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Tue Jun 7 11:26:27 2019
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> show parameter enable_ddl_logging
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
enable_ddl_logging boolean FALSE
================================================================
Difference Between 11g & 12c for enable_ddl_logging Parameter:
================================================================
In Oracle 11g:
DDL statements are written to the alert log in:
$ADR_BASE/diag/rdbms/${DBNAME}/${ORACLE_SID}/trace/alert_${ORACLE_SID}.log
1. License: The init.ora parameter ENABLE_DDL_LOGGING is licensed as part
of the Database Lifecycle Management Pack when set to TRUE. When set to
TRUE, the database reports schema changes in real time into the database alert
log under the message group schema_ddl. The default setting is FALSE.”
2. RENAME: was not logged and a bug was reported for that and the same is
fixed in 11.2.0.4. Document 12938609.8 – ENABLE_DDL_LOGGING does not
log RENAME table statements, this is fixed in 11.2.0.4
However, the feature does not log DDLs of some DBMS_STATS operations like:
set_column_stats
set_index_stats
create_extended_stats
drop_extended_stats
set_*_prefs (table/schema/global etc)
delete_pending_stats
publish_pending_stats
export_pending_stats
create_stat_table
In Oracle 12c:
Now if you look in the following text file:
$ADR_BASE/diag/rdbms/${DBNAME}/${ORACLE_SID}/log/ddl_${ORACLE_SID}.log
1. If ENABLE_DDL_LOGGING is enabled, then DDL records are written to the ADR.
2. All DDL operations like alter/create/drop/truncate objects.
3. Only drop user will be logged, But create user will not be.
How to ENABLE :
SQL> alter system set enable_ddl_logging=true;
System altered.
SQL> show parameter enable_ddl_logging;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
enable_ddl_logging boolean TRUE
How to DISABLE :
SQL> show parameter enable_ddl_logging
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
enable_ddl_logging boolean TRUE
SQL> alter system set enable_ddl_logging =FALSE;
System altered.
SQL> show parameter ENABLE_DDL_LOGGING
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
enable_ddl_logging boolean FALSE
SQL> conn syed/syed
Connected.
SQL> create table Testddl (id number, name varchar2(50));
Table created.
SQL> alter table Testddl add ( address varchar2(100));
Table altered.
SQL> insert into Testddl values (1,'CBT','XYZ');
1 row created.
SQL> commit;
Commit complete.
SQL> drop table ddltest;
Table dropped.
Note: Now, check the log file for all DDL commands that was run by user.
-bash-4.1$ pwd
/mnt/Oracle/diag/rdbms/orclnew/orclnew/log/ddl
-bash-4.1$ cat log.xml
msg_id='opiexe:4383:2946163730' type='UNKNOWN' group='diag_adl'
level='16' host_id='OraLinuxNode' host_addr='10.184.150.107'
version='1'>
create table Testddl (id number, name varchar2(50))
msg_id='opiexe:4383:2946163730' type='UNKNOWN' group='diag_adl'
level='16' host_id='OraLinuxNode' host_addr='10.184.150.107'>
alter table Testddl add ( address varchar2(100))
msg_id='opiexe:4383:2946163730' type='UNKNOWN' group='diag_adl'
level='16' host_id='OraLinuxNode' host_addr='10.184.150.107'>
drop table Testddl
=======================================================
THANK YOU
=======================================================
Written by:
Syed Sadath Ullah
M.Tech;OCP
Database Administrator
Email:oraclecloud777@gmail.com

More Related Content

DOC
Oracle dba interview question
DOCX
Dbcc.doc
PPTX
PyCon DE 2013 - Table Partitioning with Django
DOC
Oracle 9i
PDF
161 Pdfsam
PDF
MySQL USER MANAGEMENT,ROUTINES & TRIGGERS.
PDF
201 Pdfsam
PDF
Discover Database
Oracle dba interview question
Dbcc.doc
PyCon DE 2013 - Table Partitioning with Django
Oracle 9i
161 Pdfsam
MySQL USER MANAGEMENT,ROUTINES & TRIGGERS.
201 Pdfsam
Discover Database

What's hot (12)

DOC
Analyzing awr report
PPTX
Oracle Data Redaction - UKOUG - TECH14
PDF
Datamigration
DOCX
Dba 3+ exp qus
PDF
Oracle performance tuning
PPTX
Oracle Data Redaction
PPT
New Features Sql 2008
PDF
PPT
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
PDF
Database consistency in NonStop SQL/MX
PDF
Parameter substitution in Aginity Workbench
Analyzing awr report
Oracle Data Redaction - UKOUG - TECH14
Datamigration
Dba 3+ exp qus
Oracle performance tuning
Oracle Data Redaction
New Features Sql 2008
Performance Tuning With Oracle ASH and AWR. Part 1 How And What
Database consistency in NonStop SQL/MX
Parameter substitution in Aginity Workbench
Ad

Similar to DDL logging Parameter in Oracle 11g & 12c (20)

PPTX
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
PPTX
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
PPTX
Oracle database 12c new features
DOC
Steps for upgrading the database to 10g release 2
PPTX
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...
PDF
Oracle 12 c new-features
PPTX
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expr...
PPTX
Oracle-12cData-Guard-Broker-Session-4.pptx
DOCX
Oracle GoldenGate
PDF
RMAN in 12c: The Next Generation (WP)
DOC
Oracle data guard configuration in 12c
PPTX
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DOCX
Rman backup and recovery 11g new features
PPTX
Data Guard New Features
TXT
Oracle11g notes
TXT
oracle dba
PPTX
SQL Developer for DBAs
PDF
NoCOUG_201411_Patel_Managing_a_Large_OLTP_Database
PDF
oracle upgradation
DOCX
Physical_Standby_Database_R12.2.4
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
OOW16 - Oracle Database 12c - The Best Oracle Database 12c New Features for D...
Oracle database 12c new features
Steps for upgrading the database to 10g release 2
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expre...
Oracle 12 c new-features
Oracle Database 12c Release 2 - New Features On Oracle Database Exadata Expr...
Oracle-12cData-Guard-Broker-Session-4.pptx
Oracle GoldenGate
RMAN in 12c: The Next Generation (WP)
Oracle data guard configuration in 12c
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
Rman backup and recovery 11g new features
Data Guard New Features
Oracle11g notes
oracle dba
SQL Developer for DBAs
NoCOUG_201411_Patel_Managing_a_Large_OLTP_Database
oracle upgradation
Physical_Standby_Database_R12.2.4
Ad

Recently uploaded (20)

PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PPTX
The various Industrial Revolutions .pptx
PPTX
cloud_computing_Infrastucture_as_cloud_p
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PPTX
O2C Customer Invoices to Receipt V15A.pptx
PPTX
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
PPTX
observCloud-Native Containerability and monitoring.pptx
PDF
Developing a website for English-speaking practice to English as a foreign la...
PDF
Getting started with AI Agents and Multi-Agent Systems
PPTX
1. Introduction to Computer Programming.pptx
PPTX
Final SEM Unit 1 for mit wpu at pune .pptx
PDF
1 - Historical Antecedents, Social Consideration.pdf
PDF
August Patch Tuesday
PDF
A novel scalable deep ensemble learning framework for big data classification...
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
STKI Israel Market Study 2025 version august
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PPTX
TLE Review Electricity (Electricity).pptx
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
The various Industrial Revolutions .pptx
cloud_computing_Infrastucture_as_cloud_p
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
O2C Customer Invoices to Receipt V15A.pptx
MicrosoftCybserSecurityReferenceArchitecture-April-2025.pptx
observCloud-Native Containerability and monitoring.pptx
Developing a website for English-speaking practice to English as a foreign la...
Getting started with AI Agents and Multi-Agent Systems
1. Introduction to Computer Programming.pptx
Final SEM Unit 1 for mit wpu at pune .pptx
1 - Historical Antecedents, Social Consideration.pdf
August Patch Tuesday
A novel scalable deep ensemble learning framework for big data classification...
A contest of sentiment analysis: k-nearest neighbor versus neural network
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
Assigned Numbers - 2025 - Bluetooth® Document
STKI Israel Market Study 2025 version august
NewMind AI Weekly Chronicles – August ’25 Week III
TLE Review Electricity (Electricity).pptx

DDL logging Parameter in Oracle 11g & 12c

  • 1. ======================================================= DDL logging: In Oracle 11g&12c ================================================================ There was no direct option available to log the DDL action in the previous releases. 1) From 11gr2 /12cR1, you can now log the DDL action into xml and log files. 2) This will be very useful to know when the drop or create command was executed and by who. 3) The ENABLE_DDL_LOGGING initiation parameter can be set at the Database or Session levels. 4) When this parameter is enabled, all DDL commands are logged in an xml and a log file under the $ORACLE_BASE/diag/rdbms/DBNAME/log|ddl location. 5) An xml file contains information, such as DDL command, IP address, timestamp etc. 6) It helps to identify User/Table dropped (or) DDL statement is triggered. To enable DDL logging SQL> ALTER SYSTEM|SESSION SET ENABLE_DDL_LOGGING=TRUE; Note: When ENABLE_DDL_LOGGING is set to true, the following DDL statements are written to the alert log: ALTER/CREATE/DROP/TRUNCATE CLUSTER ALTER/CREATE/DROP FUNCTION ALTER/CREATE/DROP INDEX ALTER/CREATE/DROP OUTLINE ALTER/CREATE/DROP PACKAGE ALTER/CREATE/DROP PACKAGE BODY ALTER/CREATE/DROP PROCEDURE ALTER/CREATE/DROP PROFILE ALTER/CREATE/DROP SEQUENCE CREATE/DROP SYNONYM ALTER/CREATE/DROP/RENAME/TRUNCATE TABLE ALTER/CREATE/DROP TRIGGER ALTER/CREATE/DROP TYPE ALTER/CREATE/DROP TYPE BODY DROP USER ALTER/CREATE/DROP VIEW
  • 2. Following is the example of DDL logging: ====================================== -bash-4.1$ sqlplus / as sysdba SQL*Plus: Release 12.1.0.2.0 Production on Tue Jun 7 11:26:27 2019 Copyright (c) 1982, 2014, Oracle. All rights reserved. Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options SQL> show parameter enable_ddl_logging NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ enable_ddl_logging boolean FALSE ================================================================ Difference Between 11g & 12c for enable_ddl_logging Parameter: ================================================================ In Oracle 11g: DDL statements are written to the alert log in: $ADR_BASE/diag/rdbms/${DBNAME}/${ORACLE_SID}/trace/alert_${ORACLE_SID}.log 1. License: The init.ora parameter ENABLE_DDL_LOGGING is licensed as part of the Database Lifecycle Management Pack when set to TRUE. When set to TRUE, the database reports schema changes in real time into the database alert log under the message group schema_ddl. The default setting is FALSE.” 2. RENAME: was not logged and a bug was reported for that and the same is fixed in 11.2.0.4. Document 12938609.8 – ENABLE_DDL_LOGGING does not log RENAME table statements, this is fixed in 11.2.0.4 However, the feature does not log DDLs of some DBMS_STATS operations like: set_column_stats set_index_stats create_extended_stats drop_extended_stats set_*_prefs (table/schema/global etc) delete_pending_stats publish_pending_stats export_pending_stats create_stat_table
  • 3. In Oracle 12c: Now if you look in the following text file: $ADR_BASE/diag/rdbms/${DBNAME}/${ORACLE_SID}/log/ddl_${ORACLE_SID}.log 1. If ENABLE_DDL_LOGGING is enabled, then DDL records are written to the ADR. 2. All DDL operations like alter/create/drop/truncate objects. 3. Only drop user will be logged, But create user will not be. How to ENABLE : SQL> alter system set enable_ddl_logging=true; System altered. SQL> show parameter enable_ddl_logging; NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ enable_ddl_logging boolean TRUE How to DISABLE : SQL> show parameter enable_ddl_logging NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ enable_ddl_logging boolean TRUE SQL> alter system set enable_ddl_logging =FALSE; System altered. SQL> show parameter ENABLE_DDL_LOGGING NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ enable_ddl_logging boolean FALSE SQL> conn syed/syed Connected. SQL> create table Testddl (id number, name varchar2(50)); Table created. SQL> alter table Testddl add ( address varchar2(100)); Table altered.
  • 4. SQL> insert into Testddl values (1,'CBT','XYZ'); 1 row created. SQL> commit; Commit complete. SQL> drop table ddltest; Table dropped. Note: Now, check the log file for all DDL commands that was run by user. -bash-4.1$ pwd /mnt/Oracle/diag/rdbms/orclnew/orclnew/log/ddl -bash-4.1$ cat log.xml msg_id='opiexe:4383:2946163730' type='UNKNOWN' group='diag_adl' level='16' host_id='OraLinuxNode' host_addr='10.184.150.107' version='1'> create table Testddl (id number, name varchar2(50)) msg_id='opiexe:4383:2946163730' type='UNKNOWN' group='diag_adl' level='16' host_id='OraLinuxNode' host_addr='10.184.150.107'> alter table Testddl add ( address varchar2(100)) msg_id='opiexe:4383:2946163730' type='UNKNOWN' group='diag_adl' level='16' host_id='OraLinuxNode' host_addr='10.184.150.107'> drop table Testddl ======================================================= THANK YOU ======================================================= Written by: Syed Sadath Ullah M.Tech;OCP Database Administrator Email:oraclecloud777@gmail.com