Oracle 12c 启用VARCHAR2, NVARCHAR2, and RAW类型支持32K(4,000 to 32,767 bytes)

来源:互联网 发布:计算机冗余控制软件 编辑:程序博客网 时间:2024/05/17 06:02

12c新特性部分 Increased Size Limit for VARCHAR2, NVARCHAR2, and RAW Data Types
官方如下介绍:
The maximum size of the VARCHAR2, NVARCHAR2, and RAW data types has been increased from 4,000 to 32,767 bytes.
Increasing the allotted size for these data types allows users to store more information in character data types 
before switching to large objects (LOBs). This is especially useful for brief textual data types and 
the capabilities to build indexes on these types of columns.


a.默认情况下varchar2长度不能超过4000 
b.插入varchar2超过4000的字段(列长度为4000),自动被截断 


Oracle 12C支持字符串32K处理过程 
1.修改MAX_STRING_SIZE=’EXTENDED’ 
2.重启数据库至upgrade状态 
3.执行@?/rdbms/admin/utl32k.sql 
4.重启数据库至正常open状态

eg:

#############################################################################################

C:\Users\Administrator>sqlplus sys/thisris#2016824@10.1.11.212:1523/hyris as sys
dba


SQL*Plus: Release 11.2.0.1.0 Production on 星期三 8月 24 14:55:07 2016


Copyright (c) 1982, 2010, Oracle.  All rights reserved.




连接到:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing opt
ions


SQL> show parameter MAX_STRING_SIZE



NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
max_string_size                      string      STANDARD

SQL>
SQL> create table t_maxstr(id number,name varchar2(4001));
create table t_maxstr(id number,name varchar2(4001))
                                              *
第 1 行出现错误:
ORA-00910: 指定的长度对于数据类型而言过长




SQL> create table t_maxstr(id number,name varchar2(4000));


表已创建。


SQL> insert into t_maxstr values(3,lpad('t_maxstr',4009,0));


已创建 1 行。


SQL> commit;


提交完成。


SQL> select id,length(name) from t_maxstr;


        ID LENGTH(NAME)
---------- ------------
         3         4000


SQL> select id,substr(name,4000) from t_maxstr;


        ID SU
---------- --
         3 r


SQL> select id,substr(name,-10,10) from t_maxstr;


        ID SUBSTR(NAME,-10,10)
---------- --------------------
         3 00t_maxstr


SQL> select id,substr(name,-10,-10) from t_maxstr;


        ID S
---------- -
         3


SQL>

SQL> shutdown immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup upgrade
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE 例程已经启动。


Total System Global Area 1258291200 bytes
Fixed Size                  3045168 bytes
Variable Size             788531408 bytes
Database Buffers          452984832 bytes
Redo Buffers               13729792 bytes
数据库装载完毕。
数据库已经打开。
SQL> @?/rdbms/admin/utl32k.sql
SP2-0310: 无法打开文件 "c:\app\Administrator\product\11.2.0\client_1/rdbms/admin
/utl32k.sql"


SQL> show parameter db_unique_name


NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_unique_name                       string      hyris
SQL> @?/rdbms/admin/utl32k.sql


会话已更改。


DOC>#######################################################################
DOC>#######################################################################
DOC>   The following statement will cause an "ORA-01722: invalid number"
DOC>   error if the database has not been opened for UPGRADE.
DOC>
DOC>   Perform a "SHUTDOWN ABORT"  and
DOC>   restart using UPGRADE.
DOC>#######################################################################
DOC>#######################################################################
DOC>#


未选定行


DOC>#######################################################################
DOC>#######################################################################
DOC>   The following statement will cause an "ORA-01722: invalid number"
DOC>   error if the database does not have compatible >= 12.0.0
DOC>
DOC>   Set compatible >= 12.0.0 and retry.
DOC>#######################################################################
DOC>#######################################################################
DOC>#


PL/SQL 过程已成功完成。




会话已更改。




已更新0行。




提交完成。




系统已更改。




PL/SQL 过程已成功完成。




提交完成。




系统已更改。




会话已更改。




PL/SQL 过程已成功完成。


没有错误。


会话已更改。




PL/SQL 过程已成功完成。




提交完成。




程序包已变更。




程序包已变更。


SQL>
SQL> shutdown immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup
ORA-32004: obsolete or deprecated parameter(s) specified for RDBMS instance
ORACLE 例程已经启动。


Total System Global Area 1258291200 bytes
Fixed Size                  3045168 bytes
Variable Size             788531408 bytes
Database Buffers          452984832 bytes
Redo Buffers               13729792 bytes
数据库装载完毕。
数据库已经打开。
SQL>
SQL> show parameter MAX_STRING_SIZE;


NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
max_string_size                      string      EXTENDED

SQL> create table t_extend(id number,name varchar2(32768));
create table t_extend(id number,name varchar2(32768))
                                              *
第 1 行出现错误:
ORA-00910: 指定的长度对于数据类型而言过长




SQL> create table t_extend(id number,name varchar2(32767));


表已创建。


SQL> insert into t_extend values(3,lpad('t_extend',32767,0));


已创建 1 行。


SQL> commit;


提交完成。


SQL> select id,length(name) from t_extend;


        ID LENGTH(NAME)
---------- ------------
         3        32767



SQL> select id,substr(name,4000) from t_extend;
select id,substr(name,4000) from t_extend
                                 *
第 1 行出现错误:
ORA-24920: 列大小对于客户机过大


SQL> select id,substr(name,-10,-10) from t_extend;


        ID S
---------- -
         3


SQL> select id,substr(name,32767) from t_extend;


        ID SU
---------- --
         3 d


SQL>

0 0
原创粉丝点击