SQLSTATE 42601 ERROR Class 42: Syntax Error or Access Rule Violation

syntax_error ON CONFLICT DO UPDATE requires inference specification or constrain… — 42601

PostgreSQL error “ON CONFLICT DO UPDATE requires inference specification or constraint name” (SQLSTATE 42601, syntax_error): what it means, common causes, and how to fix it.

PG 15, 16, 17, 18 Official docs
Last reviewed Jun 2026 Grounded in source
Production impact Low Competency DDL & Schema Ops Career Zero-downtime migrations Frequency Rare

Investigation

Symptoms

A statement failed with SQLSTATE 42601 (syntax_error), reported at severity ERROR. This is a Syntax Error or Access Rule Violation condition: PostgreSQL emits the message ON CONFLICT DO UPDATE requires inference specification or constraint name.

  • The client receives SQLSTATE 42601 (syntax error).
  • The operation is rejected at ERROR level; the statement does not complete.

What the server log shows

ERROR:  ON CONFLICT DO UPDATE requires inference specification or constraint name
HINT:  For example, ON CONFLICT (column_name).

Why PostgreSQL raises this

Class 42 (Syntax Error or Access Rule Violation) is raised at parse/analysis time when a statement is malformed, references an object or column that cannot be resolved, or the role lacks privilege for the action.

As described in PostgreSQL’s Section 4.1 Lexical Structure and Appendix A (PostgreSQL Error Codes), SQLSTATE 42601 carries the condition name syntax_error in class Syntax Error or Access Rule Violation. (Paraphrased — see the linked reference for the exact wording.)

Common causes

  • A typo, missing keyword, or misplaced clause in the SQL text.
  • An object, column, function, or type name could not be resolved on the search_path.
  • Wrong identifier case (unquoted names fold to lower case).
  • The role lacks the privilege required for the operation.

How to fix it

  1. Read the caret (^) in the log — it points at the offending token.
  2. Schema-qualify names or fix search_path; confirm the object exists.
  3. Quote mixed-case identifiers exactly as created.
  4. Grant the required privilege or connect as a role that has it.

Version applicability

This message text is present in PostgreSQL 15, 16, 17, 18.

Related & next steps

Reference: PostgreSQL Section 4.1 Lexical Structure.

Keep going

Related & next steps

Was this helpful?