RE: Something easy? ORA-01450: maximum key length (6398) exceeded

  • From: "Wolfson Larry - lwolfs" <lawrence.wolfson@xxxxxxxxxx>
  • To: <tanel.poder.003@xxxxxxx>, "ORACLE-L" <oracle-l@xxxxxxxxxxxxx>
  • Date: Fri, 20 Jan 2006 12:09:23 -0600

 Tanel,
        Thanks for the clarity.  Maybe wasn't as easy as I thought.

        Larry

-----Original Message-----
From: oracle-l-bounce@xxxxxxxxxxxxx [mailto:oracle-l-bounce@xxxxxxxxxxxxx] On 
Behalf Of Tanel Põder
Sent: Friday, January 20, 2006 11:13 AM
To: ORACLE-L
Subject: Re: Something easy? ORA-01450: maximum key length (6398) exceeded

> If you define CLASS VARCHAR2(2000 CHAR) then you can insert 4000 chars 
> irrespective of their single- or multi- bytes.

Yep, when your NLS_LENGTH_SEMANTICS is set to CHAR (or you specify it at the 
table column level) the behavior is same, but nevertheless the settings, there 
are hard limits of 2000 BYTES for CHAR and 4000 BYTES for VARCHAR2. 
You can't exceed those.

And beware the varchar2 case (tested on 10.2.0.1)

SQL> create table t(a varchar2(4000 char));

Table created.

SQL> insert into t values(rpad('ä',4000,'ä'));

1 row created.

SQL> select length(a) from t;

 LENGTH(A)
----------
      1334


The input is silently truncated!
Char case is better, it gives an error on overflow:

SQL> insert into t values(rpad('ä',2000,'ä'));
insert into t values(rpad('ä',2000,'ä'))
                     *
ERROR at line 1:
ORA-12899: value too large for column "SYS"."T"."A" (actual: 4000, maximum: 
2000)

The index creation error was probably because the AL32UTF8 encoding was used. 
With AL32UTF8, Oracle has to count for max 4 bytes per character, thus couldn't 
allow creation of this index. If you either use UTF8 encoding (max
3 bytes per char) or just set NLS_LENGTH_SEMANTICS to BYTE before creating the 
tables.

Tanel.

--
//www.freelists.org/webpage/oracle-l
*************************************************************************
The information contained in this communication is confidential, is
intended only for the use of the recipient named above, and may be
legally privileged.

If the reader of this message is not the intended recipient, you are 
hereby notified that any dissemination, distribution or copying of this
communication is strictly prohibited.

If you have received this communication in error, please resend this
communication to the sender and delete the original message or any copy
of it from your computer system.

Thank you.
*************************************************************************
--
//www.freelists.org/webpage/oracle-l


Other related posts: