[问题描述]
将索引转移到别的表空间时,报错:
SQL> alter index XX_DESC_INDEX rebuild online tablespace XX_idx_new;
alter index XX_DESC_INDEX rebuild online tablespace XX_idx_new
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-01450: maximum key length (3215) exceeded
[问题分析]
创建索引所需要的字段,字段长度加起来超过3215,ORA报错。
conditionname VARCHAR2(800),
conditionrelation VARCHAR2(100),
conditionvalue VARCHAR2(4000)
9i之后每个index key最大可以为block size的80%。
所以理论上来说,是可以创建最大长度为block size=8096*80%约为6400左右长度的index。
但因为online创建的过程中会生成一个中间表,用来记录创建过程中的变化,而这个表是IOT表。经过测试,发现IOT表的限制比较严格,8k的block size,最大长度只能有3215,所以普通创建可以成功,而online创建则不行,关键还在背后的IOT表上。
[解决方法]
去掉online可以成功:
SQL> alter index XX_DESC_INDEX rebuild tablespace XX_idx_new;
Index altered.