[20131116]12c的EXTENDED VARCHAR2与_scalar_type_lob_storage_threshold之2.txt

[20131116]12c的EXTENDED VARCHAR2与_scalar_type_lob_storage_threshold之2.txt

参考链接:http://space.itpub.net/267265/viewspace-776807/

google查询了一些资料:

发现:
SYS@test01p> @hide _scalar_type_lob_storage_threshold;
NAME                                     DESCRIPTION                                                        DEFAULT_VALUE          SESSION_VALUE          SYSTEM_VALUE
---------------------------------------- ------------------------------------------------------------------ ---------------------- ---------------------- ----------------------
_scalar_type_lob_storage_threshold       threshold for VARCHAR2, NVARCHAR2, and RAW storage as BLOB         TRUE                   4000                   4000

--很明显这个参数可以控制字符串当作blob存储的长度,也就是缺省是4000.

--如果修改这个参数就可以控制存储长度是否选择blob方式保存的切换点。
SCOTT@test01p> @ver
BANNER                                                                               CON_ID
-------------------------------------------------------------------------------- ----------
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production              0

SYS@test01p> alter system set "_scalar_type_lob_storage_threshold"=10000;
System altered.

SCOTT@test01p> show parameter _scalar_type_lob_storage_threshold
NAME                                 TYPE                                     VALUE
------------------------------------ ---------------------------------------- ---------
_scalar_type_lob_storage_threshold   integer                                  10000

--这样长度小于等于10000的字符不会使用blob保存。

drop table t1 purge ;

SCOTT@test01p> select * from user_lobs;
no rows selected

--当前用户没有lob字段类型。

create table t1 ( id number,a varchar2(10000),b varchar2(12000));

SCOTT@test01p> select table_name,segment_name from user_lobs;
TABLE_NAME SEGMENT_NAME
---------- ------------------------------
T1         SYS_LOB0000093548C00003$$

--仅仅在第3字段使用lob。

SCOTT@test01p> create index i_t1_a on t1(a);
create index i_t1_a on t1(a)
                       *
ERROR at line 1:
ORA-01450: maximum key length (6398) exceeded

SCOTT@test01p> create index i_t1_b on t1(b);
create index i_t1_b on t1(b)
                       *
ERROR at line 1:
ORA-01450: maximum key length (6398) exceeded

--10000个字符已经超出了8K的数据块,在这些字段建立索引自然不行。当然在这么长字段建立索引意义不大。

--换一个角度思考,如果选择的数据块不是8k,而是32K应该就没有这个问题。
SCOTT@test01p> alter system set db_32k_cache_size=50M;
alter system set db_32k_cache_size=50M
*
ERROR at line 1:
ORA-65040: operation not allowed from within a pluggable database
--这个参数不允许在pdb上设置。

SYS@test> alter system set db_32k_cache_size=50M;
alter system set db_32k_cache_size=50M
*
ERROR at line 1:
ORA-32017: failure in updating SPFILE
ORA-00382: 32768 not a valid block size, valid range [2048..16384]

--windows下依旧不支持32k的数据块。
SYS@test> alter system set db_16k_cache_size=50M;
System altered.

CREATE TABLESPACE t16k DATAFILE
  'D:\APP\ORACLE\ORADATA\TEST\TEST01P\T16K01.DBF' SIZE 16M AUTOEXTEND ON NEXT 16M MAXSIZE UNLIMITED
LOGGING
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 16K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;

alter user scott quota unlimited on t16k;

SCOTT@test01p> alter table t1 move tablespace t16k;
Table altered.

SCOTT@test01p> create index i_t1_b on t1(b);
create index i_t1_b on t1(b)
                       *
ERROR at line 1:
ORA-01450: maximum key length (6398) exceeded
--不行!这样建立的索引默认users表空间。

SCOTT@test01p> create index i_t1_a on t1(a) tablespace t16k ;
Index created.

SCOTT@test01p> create index i_t1_b on t1(b) tablespace t16k ;
Index created.

--OK,通过。

总结:
1.建议这样的索引没有意义,只不过验证自己的想法是否正确。
2.也就是讲这些超长索引不是不能建,只要数据块变大,还是可以建立的,即使是在10g的环境下,当然我没有测试^_^。

--补充测试1:
SCOTT@test01p> alter system set "_scalar_type_lob_storage_threshold"=4000;
System altered.

SCOTT@test01p> create table t1 ( id number,a varchar2(10000),b varchar2(12000));
Table created.

SCOTT@test01p> select table_name,segment_name from user_lobs;
TABLE_NAME SEGMENT_NAME
---------- -------------------------
T1         SYS_LOB0000093573C00002$$
T1         SYS_LOB0000093573C00003$$

SCOTT@test01p> create index i_t1_a on t1(a) ;
create index i_t1_a on t1(a)
                       *
ERROR at line 1:
ORA-01450: maximum key length (6398) exceeded

SCOTT@test01p> create index i_t1_a on t1(a) tablespace t16k ;
Index created.

--补充测试2:
SCOTT@test> @ver
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

SCOTT@test> alter system set db_32k_cache_size=16M ;
System altered.

CREATE TABLESPACE t32k DATAFILE
  '/u01/app/oracle11g/oradata/test/t32k01.dbf' SIZE 16M AUTOEXTEND ON NEXT 16M MAXSIZE UNLIMITED
LOGGING
EXTENT MANAGEMENT LOCAL AUTOALLOCATE
BLOCKSIZE 32K
SEGMENT SPACE MANAGEMENT AUTO
FLASHBACK ON;

SCOTT@test> select * from user_lobs;
no rows selected

create table t1 ( id number,a varchar2(4000),b varchar2(4000));

SCOTT@test> create index i_t1_a_b on t1(a,b);
create index i_t1_a_b on t1(a,b)
                         *
ERROR at line 1:
ORA-01450: maximum key length (6398) exceeded
--错误两个字段加起来达到8000字节,超出了6398限制。

SCOTT@test> create index i_t1_a_b on t1(a,b) tablespace t32k;
Index created.

--建立在32K的表空间OK通过!

时间: 2024-10-01 01:48:55

[20131116]12c的EXTENDED VARCHAR2与_scalar_type_lob_storage_threshold之2.txt的相关文章

[20131116]12c的EXTENDED VARCHAR2与隐含参数_scalar_type_lob_storage_threshold.txt

[20131116]12c的EXTENDED VARCHAR2与隐含参数_scalar_type_lob_storage_threshold.txt 参考链接:http://space.itpub.net/267265/viewspace-776806/ google查询了一些资料: 发现:SYS@test01p> @hide _scalar_type_lob_storage_threshold;NAME                                     DESCRIPTI

[20131116]12c的EXTENDED VARCHAR2与CLOB字段.txt

[20131116]12c的EXTENDED VARCHAR2与CLOB字段.txt oracle 12c以前如果字符串长度超过4000,必须使用blob或者clob类型.12c开始支持超过4000的字符串长度,提高一些应用的灵活性,达到32K,避免一些字段定义为clob,blob类型,提高处理能力. 要支持这个特性,要执行 @?/rdbms/admin/utl32k.sql升级步骤.如果存在pdb库,还必须升级PDB$SEED,以及PDB数据库.参考链接:http://space.itpub.

[20130916]12c Indexing Extended Data Types and index.txt

[20130916]12c Indexing Extended Data Types and index.txt http://richardfoote.wordpress.com/2013/09/12/12c-indexing-extended-data-types-part-i-a-big-hurt/ 参考以上链接,做一些测试: 1.测试环境: SCOTT@test01p> @ver BANNER                                                

[20130915]12c新特性 varchar2支持32K长度.txt

[20130915]12c新特性 varchar2支持32K长度.txt oracle 12c以前如果字符串长度超过4000,必须使用blob或者clob类型.12c开始支持超过4000的字符串长度,提高一些应用的灵活性,达到32K,避免一些字段定义为clob,blob类型,提高处理能力. 但是12c默认的方式不支持大于4000的字符串长度,必须经过一些步骤升级完成,自己测试如下: SYS@test> @ver BANNER                                    

[20141116]12c下增加字段与缺省值.txt

[20141116]12c下增加字段与缺省值.txt --前一段时间写了一篇表增加字段与缺省值的blog. --链接如下: http://blog.itpub.net/267265/viewspace-1257035/ --12G 增加字段带缺省值,可以很快完成,不需要update表.实际上是增加一个隐含字段,通过位与的方式确定取值方式. 当时的总结如下: --增加字段带缺省值,在12c下很快完成,不需修改表,但是以后的插入要多付出2个字节的代价(不会增加9个字段带缺省值的吧^_^) --它通过

[20130812]12c Partial Indexes For Partitioned Tables Part I.txt

[20130812]12c Partial Indexes For Partitioned Tables Part I.txt 参考链接:http://richardfoote.wordpress.com/2013/07/08/12c-partial-indexes-for-partitioned-tables-part-i-ignoreland/ 更多的是重复作者的测试,加深理解: 1.测试环境: SQL> @ver BANNER                                

[20131019]12c Global Temporary table 统计信息的收集.txt

[20131019]12c Global Temporary table 统计信息的收集.txt 摘要:twp-optimizer-with-oracledb-12c-1963236.pdf Optimizer with Oracle Database 12c Session level statistics on Global Temporary Tables P22 Global temporary tables are often used to store intermediate re

[20130812]12c Partial Indexes For Partitioned Tables Part II.txt

[20130812]12c Partial Indexes For Partitioned Tables Part II.txt 参考链接:http://richardfoote.wordpress.com/2013/07/12/12c-partial-indexes-for-partitioned-tables-part-ii-vanishing-act/ 更多的是重复作者的测试,加深理解: 1.测试环境: SQL> @ver BANNER                           

[20130924]12c dbms_stats包的一些缺省参数.txt

[20130924]12c dbms_stats包的一些缺省参数.txt 11G下: SQL> @ver BANNER -------------------------------------------------------------------------------- Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production SELECT DBMS_STATS.get_param ('AU