12C-OCP升級1z-060-022

Examine the following command:
ALTER SYSTEM SET enable_ddl_logging=FALSE;
Which statement is true?
A. None of the data definition language (DDL) statements are logged in the trace file. 
B. Only DDL commands that resulted in errors are logged in the alert log file. 
C. A new log.xml file that contains the DDL statements is created, and the DDL command
details are removed from the alert log file. 
D. Only DDL commands that resulted in the creation of new database files are logged. 

正確答案:A
官方文檔的位置:
http://docs.oracle.com/cd/E11882_01/server.112/e40402/initparams085.htm#REFRN10302

生產環境經常遇到DROP、TRUNCATE、DELETE等誤操作, 
其中大部分影響較大的是DDL,11.2 設置ENABLE_DDL_LOGGING爲true後,alert中會記錄DDL操作的語句,但是沒有詳細信息: 
alter system set enable_ddl_logging = TRUE    sid='*' scope=spfile; 
12C中的開啓ENABLE_DDL_LOGGING後,會專門有一個日誌文件記錄詳細的信息。
SQL> select * from v$version;
BANNER                                                                               CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production              0
--默認沒有開啓
SQL> show parameter enable_ddl_logging
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
enable_ddl_logging                   boolean     FALSE

SQL> alter system set enable_ddl_logging=true;
System altered.
SQL> show parameter enable_ddl_logging
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
enable_ddl_logging                   boolean     TRUE

SQL> create table goolen as select * from dba_objects;
Table created.
SQL> create index ind_oid on goolen(object_id);
Index created.
SQL> alter table goolen modify(object_id not null);
Table altered.
SQL> truncate table goolen;
Table truncated.
SQL> drop table goolen purge;
Table dropped.
$ adrci
ADR base = "/opt/app/oracle"
adrci> show log
Choose the home from which to view diagnostic logs:
1: diag/tnslsnr/release-mysql/listener
2: diag/rdbms/ora12c/ora12c
Q: to quit

$ cd /opt/app/oracle/diag/rdbms/ora12c/ora12c/log
$ ls
ddl  ddl_ora12c.log  debug  test

$ cat ddl_ora12c.log 
diag_adl:create table goolen as select * from dba_objects
diag_adl:create index ind_oid on goolen(object_id)
diag_adl:alter table goolen modify(object_id not null)
diag_adl:truncate table goolen
diag_adl:drop table goolen purge

$ cat ddl/log.xml 
 msg_id='opiexe:4181:2946163730' type='UNKNOWN' group='diag_adl'
 level='16' host_id='release' host_addr='192.168.100.92'
 version='1'>
 create table goolen as select * from dba_objects
 
 msg_id='opiexe:4181:2946163730' type='UNKNOWN' group='diag_adl'
 level='16' host_id='release' host_addr='192.168.100.92'>
 create index ind_oid on goolen(object_id)
 
 msg_id='opiexe:4181:2946163730' type='UNKNOWN' group='diag_adl'
 level='16' host_id='release' host_addr='192.168.100.92'>
 alter table goolen modify(object_id not null)
 
 msg_id='opiexe:4181:2946163730' type='UNKNOWN' group='diag_adl'
 level='16' host_id='release' host_addr='192.168.100.92'>
 truncate table goolen
 
 msg_id='opiexe:4181:2946163730' type='UNKNOWN' group='diag_adl'
 level='16' host_id='release' host_addr='192.168.100.92'>
 drop table goolen purge

發佈了287 篇原創文章 · 獲贊 23 · 訪問量 56萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章