Oracle 12C -- 扩展varchar2、nvarchar2、和raw数据类型的大小限制
2015-08-10 16:59 abce 阅读(2977) 评论(0) 编辑 收藏 举报在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.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)