Monday, April 14, 2014

ORA-12899

This was tested on Oracle 11.2. If you try to update a column with a value which is too long, you will get an ORA-12899:
 
SQL> conn andrew/reid
Connected.
SQL> create table tab1 (first_name varchar2(10))
  2  /
 
Table created.
 
SQL> insert into tab1 values ('Christopher')
  2  /
insert into tab1 values ('Christopher')
                         *
ERROR at line 1:
ORA-12899: value too large for column
"ANDREW"."TAB1"."FIRST_NAME" (actual: 11, maximum: 10)
 
SQL>
 
If this happens, you can either use a shorter value:
 
SQL> insert into tab1 values ('Colin')
  2  /
 
1 row created.
 
SQL>
 
…or make the column longer:
 
SQL> alter table tab1 modify first_name varchar2(15)
 2  /
 
Table altered.
 
SQL> insert into tab1 values ('Christopher')
  2  /
 
1 row created.
 
SQL>

No comments: