Menu

PostgreSQL "relation does not exist" (42P01) when the table is right there: two causes
πŸ“°

PostgreSQL "relation does not exist" (42P01) when the table is right there: two causes

DEV Community: sqlΒ·Mer GoΒ·4 days ago
#RWWDmhad
#devtosql#devto#dev#enter#exit
Long article (582 words) β€” no AI summary yet.
Reading 0:00
15s threshold

You created the table. SELECT says ERROR: relation "..." does not exist . If it isn't a typo, it's almost always one of these:

The table lives in another schema that isn't on your search_path .

The table was created with a quoted, mixed-case name and you're querying it unquoted.

I reproduced both on PostgreSQL 17.12 in a container and ran the check and the fix. Every output below is exactly what psql printed.

1. The table is in another schema

-- as postgres CREATE SCHEMA sales AUTHORIZATION lab_a ;

-- as lab_a CREATE TABLE sales . orders ( id int PRIMARY KEY , amount numeric ) ; INSERT INTO sales .…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.