Diagnostic Queries
Symptoms
An INSERT supplied more values than the target column list (or table) has columns. PostgreSQL reports SQLSTATE 42601 (syntax_error) because the row shape does not match the target.
- The caret points at the first extra value.
- Often caused by a column being dropped or the VALUES list drifting out of sync.
- The mirror error “has more target columns than expressions” means the opposite mismatch.
What the server log shows
ERROR: INSERT has more expressions than target columns
LINE 1: INSERT INTO t (a, b) VALUES (1, 2, 3);
^
Why PostgreSQL raises this — what the manual says
As the INSERT reference (Parameters) explains:
An INSERT must supply no more values than there are target columns; providing extra expressions beyond the explicit or implicit column list leaves values with no column to receive them, so PostgreSQL reports this error.
PostgreSQL maps VALUES left-to-right onto the target column list. If there are more value expressions than target columns, the extras have nowhere to go and the statement fails with 42601.
Common causes
- An extra value in the VALUES list.
- Omitting the column list and not matching the table’s exact column count/order.
- A column dropped from the table but still present in the INSERT.
How to fix it
- Match counts: list the columns explicitly and provide exactly one value each.
- Remove the extra value, or add the missing column to the target list.
- Always specify an explicit column list so schema changes do not silently break inserts.
Related & next steps
Reference: PostgreSQL 18 — INSERT.
Thanks — noted. This helps keep the database accurate.