在12C中,varchar2,nvarchar2和raw类型从之前的4K扩展到32K
升级到12C后,参数max_string_size默认值是standard,即不改变varchar2、nvarchar2、和raw数据类型的大小限制,和11g保持一致。
SQL> show parameter max_string_size NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ max_string_size string STANDARD SQL>
开启"扩展数据类型"功能:
SQL> alter system set max_string_size=extended scope=both; alter system set max_string_size=extended scope=both * ERROR at line 1: ORA-02097: parameter cannot be modified because specified value is invalid ORA-14694: database must in UPGRADE mode to begin MAX_STRING_SIZE migration SQL> --设置该参数需要将数据以upgrade模式启动 SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> startup upgrade; ORACLE instance started. Total System Global Area 2483027968 bytes Fixed Size 3713864 bytes Variable Size 721421496 bytes Database Buffers 1744830464 bytes Redo Buffers 13062144 bytes Database mounted. Database opened. SQL> alter system set max_string_size=extended scope=both; System altered. SQL> @$ORACLE_HOME/rdbms/admin/utl32k.sql
修改以后要执行以下脚本,升级后可能会有部分对象变得无效,需要重新编译下一无效对象
SQL> @$ORACLE_HOME/rdbms/admin/utlrp.sql
升级以后,如果varchar2,nvarchar2和raw的大小超过4k,oracle内部会以LOBs的方式存储(oracle内部自己维护,不建议用户直接操作)。
然后再重启数据库!
可以做个测试:
SQL> create table v32k_t (id int,name varchar2(32000)); SQL> insert into v32k_t values(1,rpad(1,31999,‘x‘)); SQL> select * from v32k_t;
该新特性会产生以下一些影响:
(1)The creation and use of indexes is impacted (as covered in the next section in more detail).
用户可能会无法正确的创建、使用索引,或者无法插入和更新操作。 这主要受oracle的B树索引的长度限制,而B树索引的长度又受数据库块大小限制。8k大小的块所支持的索引的最大长度是6400字节。 建议可以使用substr创建函数索引,或创建hash索引;使用substr创建虚拟列,然后在虚拟列上创建索引。
(2)The limit of the combined length of concatenated character strings is increased.
(3)The length of the collation key returned by the NLSSORT function is increased.
(4)The size of some of the attributes of the XMLFormat objects is increased.
(5)The size of some expressions in some XML functions is adjusted.
时间: 2024-10-05 04:01:39