# value too long for type character varying(3)

Source: https://sqlstreak.com/sql/errors/value-too-long-for-type-character-varying · Tested on PostgreSQL 18.6 and SQLite 3.54.1; results generated 2026-11-22.


**Short answer:** The value has more characters than the column allows. Widen the column (`ALTER TABLE … ALTER COLUMN code TYPE VARCHAR(10)`), shorten the value, or use `TEXT`, which has no length limit and costs nothing extra in PostgreSQL.

## The exact messages

- PostgreSQL: `ERROR: value too long for type character varying(3)`

## How PostgreSQL prints it

```
ERROR:  value too long for type character varying(3)
```

## Why it happens

### A limit chosen too small

Codes, names and phone numbers are often longer than expected (country prefixes, accents, spaces).

### Data moved from SQLite or a spreadsheet

SQLite never checked the length, so over-long values were already there.

## The broken query

```sql
CREATE TABLE codes (code VARCHAR(3));
INSERT INTO codes VALUES ('ABCD');
SELECT * FROM codes;
```

## The fix

```sql
CREATE TABLE codes (code TEXT);
INSERT INTO codes VALUES ('ABCD');
SELECT * FROM codes;
```

TEXT takes any length. If the limit is a real rule, keep VARCHAR(n) and check or trim values before inserting.

| code |
| --- |
| ABCD |

## What SQLite does instead

SQLite accepts the declaration but never enforces the length: 'ABCD' goes into a VARCHAR(3) column whole. Data that loads fine in SQLite can fail in PostgreSQL.
