ORA-01450 maximum key length exceededCause The combined length of all the columns specified in a CREATE INDEX statement exceeded the maximum index length. The maximum index length varies by operating system. The total index length is computed as the sum of the width of all indexed columns plus the number of indexed columns. Date fields have a length of 7, character fields have their defined length, and numeric fields have a length of 22. Numeric length = (precision/2) + 1. If negative, add +1.
Action Select columns to be indexed so the total index length does not exceed the maximum index length for the operating system. See also your operating system-specific Oracle documentation.Copyright (C) 1998, Oracle Corporation
也就是说把索引列的长度太长了,改短点.

解决方案 »

  1.   

    create index ix_test3_ab on test3(a,b);ix_test3_ab 太长了,改短点
      

  2.   

    楼上的,你肯定没有测试过。不是索引名称的问题。SQL> create table test3(a varchar2(4000), b varchar2(4000));表已创建。SQL> create index ix_test3_ab on test3(a,b);
    create index ix_test3_ab on test3(a,b)
                                *
    ERROR 位于第 1 行:
    ORA-01450: 超出最大的关键字长度 (6398)SQL> DROP TABLE TEST3 CASCADE CONSTRAINTS表已丢弃。SQL> create table test3(a varchar2(400), b varchar2(400));表已创建。SQL> create index ix_test3_ab on test3(a,b);索引已创建。看出来了吧?你的两个字段建立的复合索引,单个索引项最大可能是4000+4000共计8000个字节,有可能超过6398这个限制,因此索引无法创建。如果你没有那么多内容要存储的话,就把字段定义小点。
      

  3.   

    其实我想问这个问题的根本目的在于6398这个值是怎么来的。由此可以加深对ORACLE数据储存方面的理解,有哪位老兄了解的?请教!
      

  4.   

    上google搜索 "ORA-01450"看第一篇的快照,原文打不开,快照格式比较乱,打开自己整理一下。英文的。说得很明白,不过最终的数据与实际情况有些出入。我觉得数据不是最重要的,重要的在于理解了为什么。正如这个错误在文档中的说明:与当前环境的设置有关。我的理解,这里的环境设置包括:
    DB_BLOCK_SIZE
    index 的 PCT_FREE、INITRANS
    等等参数。也就是说,这个值对于不同的平台、不同的用户设置,会不同。