Incident brief
Undefined data type
Referencing a type that has not been created (or is misspelled or out of the search_path) raises this undefined-object error; 'currency' is not a built-in type.
What lands in your log
ERROR: type "currency" does not exist
In 10 seconds
- What triggers it
- Create a table (or cast) that references a type name that does not exist.
- Fix
- Use an existing type (numeric, money, or a DOMAIN/type you have created).
- Proof
- Reproduced on PostgreSQL 18.4 → A single statement reproduces SQLSTATE 42704; the unknown type name is rejected and the LINE points at it.
Fix
What to do right now
Application-level steps for this error.
- Use an existing type (numeric, money, or a DOMAIN/type you have created).
- Create the missing type/domain first, or schema-qualify it if it lives elsewhere.
CREATE DOMAIN currency AS numeric(12,2);
CREATE TABLE ledger (amount currency);
INSERT INTO ledger VALUES (10.00);For this error
See this error live on the server
Run these against the affected instance to confirm the diagnosis before you act.
Type resolution uses exact name, schema, and search_path. Check existing types before creating a duplicate or silently substituting text.
Resolve the missing type
Replace the type from the error; to_regtype returns NULL when unresolved.
SELECT to_regtype('<schema_or_type_name>') AS resolved_type,
current_schemas(true) AS type_search_path;User-defined types available
List domains/enums/composites outside system schemas.
SELECT n.nspname AS schema_name, t.typname, t.typtype,
format_type(t.oid, NULL) AS display_name
FROM pg_type t
JOIN pg_namespace n ON n.oid = t.typnamespace
WHERE n.nspname !~ '^pg_' AND n.nspname <> 'information_schema'
ORDER BY n.nspname, t.typname;Why it happens
What PostgreSQL is telling you
The mechanism behind the error, grounded in the official manual, not paraphrased.
PostgreSQL 18 Documentation, Appendix A. PostgreSQL Error Codes (Table A.1, Class 42, Syntax Error or Access Rule Violation)
42704 → undefined_objectRead the full section on postgresql.org →
Referencing a type that does not exist
There is no type named 'currency' on the search_path, so PostgreSQL raises 'type currency does not exist'.The session continues normally
The missing-type lookup failed outside a transaction, so nothing needs to be rolled back before the next statement.Reproduce & verify
A real, single-session PostgreSQL reproduction
A literal transcript of SQL run against a live PostgreSQL instance in an isolated lab. The commands below are exactly what was executed.
- 1Create a table (or cast) that references a type name that does not exist.
- 2PostgreSQL resolves the type name and finds nothing matching in the search_path.
- 3The statement aborts with SQLSTATE 42704 and 'type currency does not exist'.
A migration referenced a 'currency' type that was never created, and the CREATE TABLE failed on the column definition.
-- The error is self-contained in one statement; no schema is required.
SELECT 'no schema needed' AS setup_note;CREATE TABLE ledger (amount currency);SELECT 'ok' AS session_after_error;What PostgreSQL actually returned
setup_note
------------------
no schema needed
(1 row)ERROR: type "currency" does not exist
LINE 1: CREATE TABLE ledger (amount currency);
^ session_after_error
---------------------
ok
(1 row)The table is created once the column uses an existing type.
Without this
Before: an unknown type aborts
With this, tested
After: a numeric column is accepted
- A second operational test: exact SQL, raw output, measured result, and engineer notes
Card required. Cancel before day 7 and you are not charged.
Connected
Everything this error touches
Every page this SQLSTATE connects to: the concept that explains it, the runbooks that fix it, the parameters you tune to prevent it, and the sibling errors it travels with. All real cross-references. Jump straight in, or open the full interactive map.
Verification
- Last verified
- 2026-07-24 (isolated lab, PostgreSQL 18.4)
- Verification scope
- Verified against PostgreSQL 18.4 in an isolated lab environment
- Audit status
- reviewed
Went further?
Pro unlocks the second lab proof
Free page stops the bleeding. Pro adds the operational test, SQLSTATE audit, and deeper evidence, same error, more certainty.