虽然我们都知道在定义较长的字段上建索引是没有意义的,但是避免不了有些同事还是会做这样的事情,刚好我遇到了,所以记录下来
SQL> select *from t;


        ID NAME
---------- --------------------
         1 a
         2 b
        10 c
         9 d
         8 e
         7 f


6 rows selected.


1.先加一个字段长度为4000的,建索引没问题,建索引加online报错。
SQL> alter  table t add describtion varchar2(4000);


Table altered.


SQL> create index ind_t_desc on t(describtion);


Index created.


SQL> drop index ind_t_desc ;                


Index dropped.


SQL> create index ind_t_desc on t(describtion) online;
create index ind_t_desc on t(describtion) online
                           *
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-01450: maximum key length (3215) exceeded




2.加一个字段长度为3200的,加online建索引没问题
SQL> alter  table t add describtion varchar2(3200);


Table altered.


SQL> create index ind_t_desc on t(describtion) online;


Index created.




3.加一个字段长度为3201的,加online建索引也没问题
SQL> alter  table t add describtion varchar2(3201);


Table altered.


SQL> create index ind_t_desc on t(describtion) online;


Index created.




4.加一个字段长度为3202的,建online报错;
SQL> alter  table t add describtion varchar2(3202);


Table altered.


SQL> create index ind_t_desc on t(describtion) online;
create index ind_t_desc on t(describtion) online
                           *
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-01450: maximum key length (3215) exceeded




09-01 05:13