// Oracle error reference

ORA-12899: value too large for column

A value is longer than the column allows. The message names the column and gives the actual and maximum length, often in bytes rather than characters.

Error code
ORA-12899
Category
Data values and conversion
Error message
value too large for column string (actual: string, maximum: string)

What it means

ORA-12899 means a string doesn't fit its column, for example ORA-12899: value too large for column "SALES"."CUSTOMERS"."NAME" (actual: 61, maximum: 50). A VARCHAR2(50) column is 50 bytes by default (NLS_LENGTH_SEMANTICS = BYTE), so text with accented or non-Latin characters, which take 2 to 4 bytes each in AL32UTF8, can overflow a column that looks long enough.

Common causes

  • The data is longer than the column definition.
  • Multi-byte characters in a column sized in bytes.
  • Migrating to a Unicode database character set, which makes some strings longer in bytes.

How to fix it

  1. Find the longest values that would go into the column, and compare with its definition.

    SELECT column_name, data_type, data_length, char_length, char_used
    FROM all_tab_columns WHERE table_name = 'CUSTOMERS' AND column_name = 'NAME';
  2. Widen the column, and size it in characters if it holds text in many languages.

    ALTER TABLE customers MODIFY (name VARCHAR2(200 CHAR));
  3. Or truncate deliberately before inserting, if losing the tail is acceptable.

    INSERT INTO customers (name) VALUES (SUBSTR(:name, 1, 50));

Related errors

More data values and conversion errors

The code and message text are from the Oracle Database Error Help. Browse the full Oracle error list or search every database error.

// fewer errors, faster fixes

Work on Oracle in SQLly

A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for Oracle and the other databases you use.