[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

时间: 2024-09-23 00:59:04

[20131128]12c的dbms_utility.expand_sql_text.txt的相关文章

[20170620]11G 12c expand sql text.txt

[20170620]11G 12c expand sql text.txt --//原来写的脚本只能分别在11g,12c单独使用.上午花一点点时间.把两者整合起来. --//讨论链接:http://www.itpub.net/thread-2088981-1-1.html --//再次感谢solomon_007的指点: set long 20000 set serveroutput on declare     L_sqltext clob := null;     l_version varc

[20171106]DBMS_UTILITY.GET_TIME().txt

[20171106]DBMS_UTILITY.GET_TIME().txt --//有时候测试某个脚本运行时间,经常在这之前之后调用这个函数.今天奇怪的发现显示竟然是负数,感觉很奇怪做一个探究. 1.环境: SCOTT@book> @ &r/ver1 PORT_STRING                    VERSION        BANNER ------------------------------ -------------- -----------------------

[20170114]12c varchar2类型直方图.txt

[20170114]12c varchar2类型直方图.txt --我曾经提到慎用nvarchar2数据类型,链接:http://blog.itpub.net/267265/viewspace-2120925/ --我那里提到数据类型nvarchar2类型,因为1个字符占用2个字节,这样如果前面16个字符重复很多,直方图的建立就是鸡肋, --毫无用处(因为分析仅仅对前面32个字节有效),12c 直方图支持更多类型: 高度直方图,频率直方图.混和类型(HYBRID). --看看12c关于直方图方面

[20170603]12c Top Frequency histogram.txt

[20170603]12c Top Frequency histogram.txt --//个人对直方图了解很少,以前2种直方图类型对于目前的许多应用来讲已经足够,或者讲遇到的问题很少. --//抽一点点时间,简单探究12c Top Frequency histogram. --//以前的频率直方图Frequency histogram,受限bucket(桶的大小),如果有255个不同值,oracle分析后不会建立频率直方图,而是建立高 --//度直方图.这样的情况会导致一些流行值的统计在显示执

[20160806]12c 与 WMSYS.WM_CONCAT.txt

[20160806]12c 与 WMSYS.WM_CONCAT.txt --前几天有人问临时表空间消耗的问题,链接: http://www.itpub.net/thread-2065053-1-1.html --我提到11g的wmsys.wm_concat也会使用临时表空间. --链接:http://blog.itpub.net/267265/viewspace-1356256/ --但是在12c测试发现12c已经不存在WMSYS.WM_CONCAT,看来要建议开发不要在使用它连接字符串. --

[20131109]deferred segment creation与12c的exp命令.txt

[20131109]deferred segment creation与12c的exp命令.txt 参考链接:http://space.itpub.net/267265/viewspace-713311 昨天想导出一些数据在自己的12c测试环境,发现具有段延迟建立特性的表使用exp也能导出. 例子如下: SCOTT@test01p> @ver BANNER                                                                       

[20130809]12c Clustering Factor(2).txt

[20130809]12c Clustering Factor(2).txt 参考以下链接,自己重复测试: http://richardfoote.wordpress.com/2013/05/14/clustering-factor-calculation-improvement-part-ii-blocks-on-blocks/ 1.测试环境: SQL> @ver BANNER                                                           

[20130803]ORACLE 12C RMAN 功能增强.txt

[20130803]ORACLE 12C RMAN 功能增强.txt 在oracle 12c rman中可以直接输入sql语句,缺点就是仅仅输出最大仅仅80列,不知道如何调整. d:\tmp>rman target sys/xxxx@test01p Recovery Manager: Release 12.1.0.1.0 - Production on Fri Aug 2 22:53:49 2013 Copyright (c) 1982, 2013, Oracle and/or its affi

[20170726]11G 12c expand sql text 2.txt

[20170726]11G 12c expand sql text 2.txt --//原来写的脚本只能分别在11g,12c单独使用.上午花一点点时间.把两者整合起来. --//讨论链接:http://www.itpub.net/thread-2088981-1-1.html --//感谢solomon_007的指点,通过建立动态sql语句来实现.链接:http://blog.itpub.net/267265/viewspace-2141010/ --//qqjue给出建立建立类似c的宏来实现C