[20131128]12c的dbms_utility.expand_sql_text.txt
[20131128]12c的dbms_utility.expand_sql_text.txt
SCOTT@ztest> @ver
BANNER CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
12C的dbms_utility提供了新函式expand_sql_text可以看sql容易。
例子:
SCOTT@ztest> @ver
BANNER CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
variable x clob;
begin
dbms_utility.expand_sql_text ( input_sql_text => 'select * from dba_tablespaces', output_sql_text => :x );
end;
/
SCOTT@ztest> column x format a200
SCOTT@ztest> print :x;
X
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SELECT "A1"."TABLESPACE_NAME" "TABLESPACE_NAME","A1"."BLOCK_SIZE" "BLOCK_SIZE","A1"."INITIAL_EXTENT" "INITIAL_EXTENT","A1"."NEXT_EXTENT" "NEXT_EXTENT","A1"."MIN_EXTENTS" "MIN_EXTENTS","A1"."MAX_EXTE
NTS" "MAX_EXTENTS","A1"."MAX_SIZE" "MAX_SIZE","A1"."PCT_INCREASE" "PCT_INCREASE","A1"."MIN_EXTLEN" "MIN_EXTLEN","A1"."STATUS" "STATUS","A1"."CONTENTS" "CONTENTS","A1"."LOGGING" "LOGGING","A1"."FORCE
_LOGGING" "FORCE_LOGGING","A1"."EXTENT_MANAGEMENT" "EXTENT_MANAGEMENT","A1"."ALLOCATION_TYPE" "ALLOCATION_TYPE","A1"."PLUGGED_IN" "PLUGGED_IN","A1"."SEGMENT_SPACE_MANAGEMENT" "SEGMENT_SPACE_MANAGEME
NT","A1"."DEF_TAB_COMPRESSION" "DEF_TAB_COMPRESSION","A1"."RETENTION" "RETENTION","A1"."BIGFILE" "BIGFILE","A1"."PREDICATE_EVALUATION" "PREDICATE_EVALUATION","A1"."ENCRYPTED" "ENCRYPTED","A1"."COMPR
ESS_FOR" "COMPRESS_FOR" FROM (SELECT "A3"."NAME" "TABLESPACE_NAME","A3"."BLOCKSIZE" "BLOCK_SIZE","A3"."BLOCKSIZE"*"A3"."DFLINIT" "INITIAL_EXTENT",DECODE(BITAND("A3"."FLAGS",3),1,TO_NUMBER(NULL),"A3
"."BLOCKSIZE"*"A3"."DFLINCR") "NEXT_EXTENT","A3"."DFLMINEXT" "MIN_EXTENTS",DECODE("A3"."CONTENTS$",1,TO_NUMBER(NULL),"A3"."DFLMAXEXT") "MAX_EXTENTS",DECODE(BITAND("A3"."FLAGS",4096),4096,"A3"."AFFST
RENGTH",NULL) "MAX_SIZE",DECODE(BITAND("A3"."FLAGS",3),1,TO_NUMBER(NULL),"A3"."DFLEXTPCT") "PCT_INCREASE","A3"."BLOCKSIZE"*"A3"."DFLMINLEN" "MIN_EXTLEN",DECODE("A3"."ONLINE$",1,'ONLINE',2,'OFFLINE',
4,'READ ONLY','UNDEFINED') "STATUS",DECODE("A3"."CONTENTS$",0,DECODE(BITAND("A3"."FLAGS",16),16,'UNDO','PERMANENT'),1,'TEMPORARY') "CONTENTS",DECODE(BITAND("A3"."DFLOGGING",1),0,'NOLOGGING',1,'LOGGI
NG') "LOGGING",DECODE(BITAND("A3"."DFLOGGING",2),0,'NO',2,'YES') "FORCE_LOGGING",DECODE("A3"."BITMAPPED",0,'DICTIONARY','LOCAL') "EXTENT_MANAGEMENT",DECODE(BITAND("A3"."FLAGS",3),0,'USER',1,'SYSTEM'
,2,'UNIFORM','UNDEFINED') "ALLOCATION_TYPE",DECODE("A3"."PLUGGED",0,'NO','YES') "PLUGGED_IN",DECODE(BITAND("A3"."FLAGS",32),32,'AUTO','MANUAL') "SEGMENT_SPACE_MANAGEMENT",DECODE(BITAND("A3"."FLAGS",
64),64,'ENABLED','DISABLED') "DEF_TAB_COMPRESSION",DECODE(BITAND("A3"."FLAGS",16),16,DECODE(BITAND("A3"."FLAGS",512),512,'GUARANTEE','NOGUARANTEE'),'NOT APPLY') "RETENTION",DECODE(BITAND("A3"."FLAGS
",256),256,'YES','NO') "BIGFILE",DECODE("A2"."STORATTR",1,'STORAGE','HOST') "PREDICATE_EVALUATION",DECODE(BITAND("A3"."FLAGS",16384),16384,'YES','NO') "ENCRYPTED",DECODE(BITAND("A3"."FLAGS",64),0,NU
LL,CASE WHEN BITAND("A3"."FLAGS",65536)=65536 THEN 'OLTP' WHEN BITAND("A3"."FLAGS",131072+262144)=131072 THEN 'QUERY LOW'||DECODE(BITAND("A3"."FLAGS",4194304),4194304,' ROW LEVEL LOCKING','') WHEN
BITAND("A3"."FLAGS",131072+262144)=262144 THEN 'QUERY HIGH'||DECODE(BITAND("A3"."FLAGS",4194304),4194304,' ROW LEVEL LOCKING','') WHEN BITAND("A3"."FLAGS",131072+262144)=131072+262144 THEN 'ARCHIVE
LOW'||DECODE(BITAND("A3"."FLAGS",4194304),4194304,' ROW LEVEL LOCKING','') WHEN BITAND("A3"."FLAGS",524288)=524288 THEN 'ARCHIVE HIGH'||DECODE(BITAND("A3"."FLAGS",4194304),4194304,' ROW LEVEL LOCKIN
G','') ELSE 'BASIC' END ) "COMPRESS_FOR" FROM "SYS"."TS$" "A3","SYS"."X$KCFISTSA" "A2" WHERE "A3"."ONLINE$"<>3 AND BITAND("A3"."FLAGS",2048)<>2048 AND "A3"."TS#"="A2"."TSID") "A1"
SCOTT@ztest> select text from dba_views where view_name='DBA_TABLESPACES';
TEXT
------------------------------------------------------------------------------
select ts.name, ts.blocksize, ts.blocksize * ts.dflinit,
decode(bitand(ts.flags, 3), 1, to_number(NULL),
ts.blocksize * ts.dflincr),
ts.dflminext,
decode(ts.contents$, 1, to_number(NULL), ts.dflmaxext),
decode(bitand(ts.flags, 4096), 4096, ts.affstrength, NULL),
decode(bitand(ts.flags, 3), 1, to_number(NULL), ts.dflextpct),
ts.blocksize * ts.dflminlen,
decode(ts.online$, 1, 'ONLINE', 2, 'OFFLINE',
4, 'READ ONLY', 'UNDEFINED'),
decode(ts.contents$, 0, (decode(bitand(ts.flags, 16), 16, 'UNDO',
'PERMANENT')), 1, 'TEMPORARY'),
decode(bitand(ts.dflogging, 1), 0, 'NOLOGGING', 1, 'LOGGING'),
decode(bitand(ts.dflogging, 2), 0, 'NO', 2, 'YES'),
decode(ts.bitmapped, 0, 'DICTIONARY', 'LOCAL'),
decode(bitand(ts.flags, 3), 0, 'USER', 1, 'SYSTEM', 2, 'UNIFORM',
'UNDEFINED'),
decode(ts.plugged, 0, 'NO', 'YES'),
decode(bitand(ts.flags,32), 32,'AUTO', 'MANUAL'),
decode(bitand(ts.flags,64), 64,'ENABLED', 'DISABLED'),
decode(bitand(ts.flags,16), 16, (decode(bitand(ts.flags, 512), 512,
'GUARANTEE', 'NOGUARANTEE')), 'NOT APPLY'),
decode(bitand(ts.flags,256), 256, 'YES', 'NO'),
decode(tsattr.storattr, 1, 'STORAGE', 'HOST'),
decode(bitand(ts.flags,16384), 16384, 'YES', 'NO'),
decode(bitand(ts.flags,64), 0, null,
(case when bitand(ts.flags, 65536) = 65536
then 'OLTP'
when bitand(ts.flags, (131072+262144)) = 131072
then concat('QUERY LOW',
decode(bitand(ts.flags, 4194304), 4194304,
' ROW LEVEL LOCKING', ''))
when bitand(ts.flags, (131072+262144)) = 262144
then concat('QUERY HIGH',
decode(bitand(ts.flags, 4194304), 4194304,
' ROW LEVEL LOCKING', ''))
when bitand(ts.flags, (131072+262144)) = (131072+262144)
then concat('ARCHIVE LOW',
decode(bitand(ts.flags, 4194304), 4194304,
' ROW LEVEL LOCKING', ''))
when bitand(ts.flags, 524288) = 524288
then concat('ARCHIVE HIGH',
decode(bitand(ts.flags, 4194304), 4194304,
' ROW LEVEL LOCKING', ''))
else 'BASIC' end))
from sys.ts$ ts, sys.x$kcfistsa tsattr
where ts.online$ != 3
and bitand(flags,2048) != 2048
and ts.ts# = tsattr.tsid
SCOTT@ztest> @ver
BANNER CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
12C的dbms_utility提供了新函式expand_sql_text可以看sql容易。
例子:
SCOTT@ztest> @ver
BANNER CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
variable x clob;
begin
dbms_utility.expand_sql_text ( input_sql_text => 'select * from dba_tablespaces', output_sql_text => :x );
end;
/
SCOTT@ztest> column x format a200
SCOTT@ztest> print :x;
X
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SELECT "A1"."TABLESPACE_NAME" "TABLESPACE_NAME","A1"."BLOCK_SIZE" "BLOCK_SIZE","A1"."INITIAL_EXTENT" "INITIAL_EXTENT","A1"."NEXT_EXTENT" "NEXT_EXTENT","A1"."MIN_EXTENTS" "MIN_EXTENTS","A1"."MAX_EXTE
NTS" "MAX_EXTENTS","A1"."MAX_SIZE" "MAX_SIZE","A1"."PCT_INCREASE" "PCT_INCREASE","A1"."MIN_EXTLEN" "MIN_EXTLEN","A1"."STATUS" "STATUS","A1"."CONTENTS" "CONTENTS","A1"."LOGGING" "LOGGING","A1"."FORCE
_LOGGING" "FORCE_LOGGING","A1"."EXTENT_MANAGEMENT" "EXTENT_MANAGEMENT","A1"."ALLOCATION_TYPE" "ALLOCATION_TYPE","A1"."PLUGGED_IN" "PLUGGED_IN","A1"."SEGMENT_SPACE_MANAGEMENT" "SEGMENT_SPACE_MANAGEME
NT","A1"."DEF_TAB_COMPRESSION" "DEF_TAB_COMPRESSION","A1"."RETENTION" "RETENTION","A1"."BIGFILE" "BIGFILE","A1"."PREDICATE_EVALUATION" "PREDICATE_EVALUATION","A1"."ENCRYPTED" "ENCRYPTED","A1"."COMPR
ESS_FOR" "COMPRESS_FOR" FROM (SELECT "A3"."NAME" "TABLESPACE_NAME","A3"."BLOCKSIZE" "BLOCK_SIZE","A3"."BLOCKSIZE"*"A3"."DFLINIT" "INITIAL_EXTENT",DECODE(BITAND("A3"."FLAGS",3),1,TO_NUMBER(NULL),"A3
"."BLOCKSIZE"*"A3"."DFLINCR") "NEXT_EXTENT","A3"."DFLMINEXT" "MIN_EXTENTS",DECODE("A3"."CONTENTS$",1,TO_NUMBER(NULL),"A3"."DFLMAXEXT") "MAX_EXTENTS",DECODE(BITAND("A3"."FLAGS",4096),4096,"A3"."AFFST
RENGTH",NULL) "MAX_SIZE",DECODE(BITAND("A3"."FLAGS",3),1,TO_NUMBER(NULL),"A3"."DFLEXTPCT") "PCT_INCREASE","A3"."BLOCKSIZE"*"A3"."DFLMINLEN" "MIN_EXTLEN",DECODE("A3"."ONLINE$",1,'ONLINE',2,'OFFLINE',
4,'READ ONLY','UNDEFINED') "STATUS",DECODE("A3"."CONTENTS$",0,DECODE(BITAND("A3"."FLAGS",16),16,'UNDO','PERMANENT'),1,'TEMPORARY') "CONTENTS",DECODE(BITAND("A3"."DFLOGGING",1),0,'NOLOGGING',1,'LOGGI
NG') "LOGGING",DECODE(BITAND("A3"."DFLOGGING",2),0,'NO',2,'YES') "FORCE_LOGGING",DECODE("A3"."BITMAPPED",0,'DICTIONARY','LOCAL') "EXTENT_MANAGEMENT",DECODE(BITAND("A3"."FLAGS",3),0,'USER',1,'SYSTEM'
,2,'UNIFORM','UNDEFINED') "ALLOCATION_TYPE",DECODE("A3"."PLUGGED",0,'NO','YES') "PLUGGED_IN",DECODE(BITAND("A3"."FLAGS",32),32,'AUTO','MANUAL') "SEGMENT_SPACE_MANAGEMENT",DECODE(BITAND("A3"."FLAGS",
64),64,'ENABLED','DISABLED') "DEF_TAB_COMPRESSION",DECODE(BITAND("A3"."FLAGS",16),16,DECODE(BITAND("A3"."FLAGS",512),512,'GUARANTEE','NOGUARANTEE'),'NOT APPLY') "RETENTION",DECODE(BITAND("A3"."FLAGS
",256),256,'YES','NO') "BIGFILE",DECODE("A2"."STORATTR",1,'STORAGE','HOST') "PREDICATE_EVALUATION",DECODE(BITAND("A3"."FLAGS",16384),16384,'YES','NO') "ENCRYPTED",DECODE(BITAND("A3"."FLAGS",64),0,NU
LL,CASE WHEN BITAND("A3"."FLAGS",65536)=65536 THEN 'OLTP' WHEN BITAND("A3"."FLAGS",131072+262144)=131072 THEN 'QUERY LOW'||DECODE(BITAND("A3"."FLAGS",4194304),4194304,' ROW LEVEL LOCKING','') WHEN
BITAND("A3"."FLAGS",131072+262144)=262144 THEN 'QUERY HIGH'||DECODE(BITAND("A3"."FLAGS",4194304),4194304,' ROW LEVEL LOCKING','') WHEN BITAND("A3"."FLAGS",131072+262144)=131072+262144 THEN 'ARCHIVE
LOW'||DECODE(BITAND("A3"."FLAGS",4194304),4194304,' ROW LEVEL LOCKING','') WHEN BITAND("A3"."FLAGS",524288)=524288 THEN 'ARCHIVE HIGH'||DECODE(BITAND("A3"."FLAGS",4194304),4194304,' ROW LEVEL LOCKIN
G','') ELSE 'BASIC' END ) "COMPRESS_FOR" FROM "SYS"."TS$" "A3","SYS"."X$KCFISTSA" "A2" WHERE "A3"."ONLINE$"<>3 AND BITAND("A3"."FLAGS",2048)<>2048 AND "A3"."TS#"="A2"."TSID") "A1"
SCOTT@ztest> select text from dba_views where view_name='DBA_TABLESPACES';
TEXT
------------------------------------------------------------------------------
select ts.name, ts.blocksize, ts.blocksize * ts.dflinit,
decode(bitand(ts.flags, 3), 1, to_number(NULL),
ts.blocksize * ts.dflincr),
ts.dflminext,
decode(ts.contents$, 1, to_number(NULL), ts.dflmaxext),
decode(bitand(ts.flags, 4096), 4096, ts.affstrength, NULL),
decode(bitand(ts.flags, 3), 1, to_number(NULL), ts.dflextpct),
ts.blocksize * ts.dflminlen,
decode(ts.online$, 1, 'ONLINE', 2, 'OFFLINE',
4, 'READ ONLY', 'UNDEFINED'),
decode(ts.contents$, 0, (decode(bitand(ts.flags, 16), 16, 'UNDO',
'PERMANENT')), 1, 'TEMPORARY'),
decode(bitand(ts.dflogging, 1), 0, 'NOLOGGING', 1, 'LOGGING'),
decode(bitand(ts.dflogging, 2), 0, 'NO', 2, 'YES'),
decode(ts.bitmapped, 0, 'DICTIONARY', 'LOCAL'),
decode(bitand(ts.flags, 3), 0, 'USER', 1, 'SYSTEM', 2, 'UNIFORM',
'UNDEFINED'),
decode(ts.plugged, 0, 'NO', 'YES'),
decode(bitand(ts.flags,32), 32,'AUTO', 'MANUAL'),
decode(bitand(ts.flags,64), 64,'ENABLED', 'DISABLED'),
decode(bitand(ts.flags,16), 16, (decode(bitand(ts.flags, 512), 512,
'GUARANTEE', 'NOGUARANTEE')), 'NOT APPLY'),
decode(bitand(ts.flags,256), 256, 'YES', 'NO'),
decode(tsattr.storattr, 1, 'STORAGE', 'HOST'),
decode(bitand(ts.flags,16384), 16384, 'YES', 'NO'),
decode(bitand(ts.flags,64), 0, null,
(case when bitand(ts.flags, 65536) = 65536
then 'OLTP'
when bitand(ts.flags, (131072+262144)) = 131072
then concat('QUERY LOW',
decode(bitand(ts.flags, 4194304), 4194304,
' ROW LEVEL LOCKING', ''))
when bitand(ts.flags, (131072+262144)) = 262144
then concat('QUERY HIGH',
decode(bitand(ts.flags, 4194304), 4194304,
' ROW LEVEL LOCKING', ''))
when bitand(ts.flags, (131072+262144)) = (131072+262144)
then concat('ARCHIVE LOW',
decode(bitand(ts.flags, 4194304), 4194304,
' ROW LEVEL LOCKING', ''))
when bitand(ts.flags, 524288) = 524288
then concat('ARCHIVE HIGH',
decode(bitand(ts.flags, 4194304), 4194304,
' ROW LEVEL LOCKING', ''))
else 'BASIC' end))
from sys.ts$ ts, sys.x$kcfistsa tsattr
where ts.online$ != 3
and bitand(flags,2048) != 2048
and ts.ts# = tsattr.tsid
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-1061657/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 12c系列(十) | 12c中的Recovering Tables and Table PartitionsOracle
- goldengate 12c 針對oracle 12c配置的主要變化GoOracle
- Oracle 12c與GoldenGate 12c的一些問答OracleGo
- 【12c Partitioning】Oracle 12c Partitioning特性Oracle
- Oracle 12cOracle
- Oracle 12c系列(二)|PDB的建立Oracle
- oracle 12C rman下表的恢復Oracle
- Oracle 12C GDSOracle
- 12c安裝
- 12c多租戶架構下部署GoldenGate 12c架構Go
- 12c multitenant database 的使用者管理NaNDatabase
- TOM 大師眼中的12c改進
- goldengate 12c對teradata的支援Go
- 12c ojdbc7的下載位置JDBC
- 【OCM】Oracle 12C OCMU 12c OCM升級考試大綱Oracle
- Oracle 12C安裝Oracle
- 12c pdb基本操作
- Oracle 12c新特性Oracle
- Oracle 12c Relocate PDBOracle
- Oracle 12c Refreshable CloneOracle
- Oracle 12c RAC: MGMTDBOracle
- ORACLE 12C EM ExpressOracleExpress
- 12C SQL-TOPSQL
- Oracle 12C配置EMOracle
- ORACLE 12c Core DocOracle
- 12c in-database archiveDatabaseHive
- 12c EM Database ExpressDatabaseExpress
- 12c em安裝
- Oracle 12c - Data RedactionOracle
- oracle 12c 釋出Oracle
- 12c new feature
- 【12c】12c RMAN新特性之recover table(表級別恢復)
- 【12C】Oracle 12C 新特性“可插拔資料庫”功能體驗Oracle資料庫
- ORACLE 12c索引分裂引起的會話夯Oracle索引會話
- ORACLE 12C RAC資料庫的啟停Oracle資料庫
- 使用12c PDB整合環境的總結
- Oracle 12c新特性之Sequence的Session特性OracleSession
- Oracle 12c裡的幾點補充(一)Oracle