SQLSTATE reference
Every PostgreSQL error, indexed by class
PostgreSQL groups every error code into a two-character class. Below is the full catalog, organized the same way the official manual is — jump to a class, then open any code for the lab-reproduced explanation.
Class 08 · Connection Exception
2 codesClass 0A · Feature Not Supported
1 codeClass 0Z · Other
1 codeClass 20 · Other
1 codeClass 21 · Cardinality Violation
1 codeClass 22 · Data Exception
32 codesValue too long for character varying(n)
Numeric value out of range
Null value not allowed
Invalid datetime format
Datetime field overflow
Time zone displacement out of range
Sequence reached its maximum value
Invalid XML document (DOCUMENT)
Invalid XML content (CONTENT)
Invalid XML comment
Invalid XML processing instruction
Negative substring length not allowed
Division by zero
Negative window frame offset
ntile argument must be positive
Interval field overflow
nth_value argument must be positive
Invalid regular expression
Logarithm of a negative number
Zero raised to a negative power
width_bucket count must be positive
LIMIT must not be negative
Negative OFFSET in a query
Invalid byte sequence for encoding
date_trunc invalid field
Invalid LIKE ESCAPE string
String data length mismatch
No SQL/JSON item for path (ON EMPTY)
JSON_VALUE must return a single scalar
Invalid input syntax
COPY: extra data after last column
Untranslatable character between encodings
Class 23 · Integrity Constraint Violation
6 codesRESTRICT foreign-key violation
Null value in column violates not-null constraint
Insert or update violates foreign key constraint
Duplicate key value violates unique constraint
New row violates check constraint
New row violates exclusion constraint
Class 25 · Invalid Transaction State
6 codesCOPY FREEZE with prior transaction activity
Active SQL transaction
Read-only SQL transaction
No active SQL transaction
Current transaction is aborted, commands ignored until end of transaction block
Idle in transaction session timeout
Class 26 · Other
1 codeClass 28 · Invalid Authorization Specification
1 codeClass 2B · Dependent Privilege Descriptors Still Exist
1 codeClass 2F · Other
1 codeClass 34 · Other
1 codeClass 3B · Other
1 codeClass 3D · Invalid Catalog Name
1 codeClass 3F · Invalid Schema Name
1 codeClass 40 · Transaction Rollback
2 codesClass 42 · Syntax Error or Access Rule Violation
29 codesPermission denied
Syntax error
Column specified more than once
Column reference is ambiguous
Column does not exist
Undefined data type
Duplicate object
Duplicate table alias
Duplicate function
Column must appear in GROUP BY
UNION types cannot be matched
Wrong object type (DROP INDEX on a table)
No unique constraint for foreign key
Cannot coerce
Function does not exist
Cannot insert a non-DEFAULT value into a GENERATED ALWAYS column
Reserved schema name (pg_ prefix)
Relation does not exist
Undefined parameter
Duplicate cursor
Duplicate prepared statement
Duplicate schema
Relation already exists
ORDER BY position out of range
Duplicate function parameter name
Multiple primary keys not allowed
Index expression must be immutable
Collation mismatch (explicit collations)
Indeterminate collation