Diagnostic Queries
Symptoms
A query tried to reference an object in another database using a database-qualified name. PostgreSQL does not support cross-database queries and raises SQLSTATE 0A000 (feature_not_supported).
- Triggered by names like
otherdb.public.table. - A single connection can only see objects in its own database.
- Use foreign data wrappers or dblink for cross-database access.
What the server log shows
ERROR: cross-database references are not implemented: "otherdb.public.orders"
Why PostgreSQL raises this — what the manual says
As the postgres_fdw documentation explains:
PostgreSQL does not support directly referencing tables that live in another database from within a single query; to read data in a different database, map its tables into the current one with a foreign-data wrapper such as postgres_fdw (or use the dblink module).
Each connection is bound to one database; the planner cannot resolve names that reference a different database, so it rejects them with 0A000. Cross-database access requires an external mechanism.
Common causes
- Writing a three-part name with a different database prefix.
- Porting SQL from systems that support cross-database queries.
- Expecting
db.schema.tableto span databases.
How to fix it
- Use the
postgres_fdwextension to query foreign tables. - Use the
dblinkextension for ad-hoc cross-database calls. - Consolidate the objects into one database (use schemas to separate them).
Related & next steps
Reference: PostgreSQL 18 — postgres_fdw.
Thanks — noted. This helps keep the database accurate.