Relation "xyz" does not exist #885
-
This is going to be a fun tool! I'm on a Mac and got sqlpage working with sqlite but then installed Postgres v17 and can connect with DBeaver just fine but SQLPage not so. There is no password set up for my db in Postgres and it defaults to a user of postgres. I edited my json file to be "database_url": "postgres://localhost:5432/mytestdb". sqlpage starts without errors but when I try to reference a table in the database I get the relation... error. Why? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
👋 Hello and welcome to SQLPage! The “relation does not exist” error means that you're successfully connected to postgres, but are trying to query a table that does not exist. With SQLite, naming isn’t an issue, but in Postgres unquoted identifiers are automatically lower-cased. If your table was created with upper-case letters or special characters, you need to quote them. Also, verify that the connection URL is actually targeting the database and schema where your table exists (typically the “public” schema). Adjusting your table naming or explicitly quoting identifiers should resolve the error. To spot the difference, you can run the following queries, one at a time, from dbeaver then from SQLPage: SELECT current_database(), current_user;
SELECT current_setting('search_path');
SELECT table_schema, table_name FROM information_schema.tables;
SELECT * FROM pg_catalog.pg_tables WHERE tablename = 'your_table';
SELECT * FROM "YourTable"; -- if created with quotes and mixed case Identifier Resolution and Case SensitivityUnquoted vs. Quoted Identifiers A table created as CREATE TABLE mytable (id SERIAL PRIMARY KEY); is stored as mytable, and any reference like SELECT * FROM MYTABLE; is interpreted as mytable. If you create a table with quotes and mixed case, for example: CREATE TABLE "MyTable" (id SERIAL PRIMARY KEY); PostgreSQL treats "MyTable" as case-sensitive. Every query must then refer to it exactly as "MyTable" with the same letter casing. Schema Resolution and the Search PathSchemas in PostgreSQLTables are organized into schemas. By default, if you don’t specify a schema, tables go into the public schema. Search PathWhen you issue an unqualified table reference (e.g., SELECT * FROM mytable;), PostgreSQL looks for the table in the schemas listed in the search_path. To see the current search path, run: SHOW search_path; If your table is in a different schema (say, sales), either qualify the table name: SELECT * FROM sales.mytable; or adjust the search path: SET search_path TO sales, public; To verify if your table exists in another schema, run: SELECT table_schema, table_name Directly Check the System CatalogYou can search for your table in PostgreSQL’s catalog. Replace your_table with the exact table name (remember the case!): SELECT * Query with Case SensitivityIf your table was created using quotes (e.g., "MyTable"), make sure you reference it with the correct case: SELECT * FROM "MyTable"; Common Pitfalls and Their ResolutionsCase Mismatch: Wrong Schema: Incorrect Database Connection: Insufficient Permissions: |
Beta Was this translation helpful? Give feedback.
👋 Hello and welcome to SQLPage!
The “relation does not exist” error means that you're successfully connected to postgres, but are trying to query a table that does not exist.
With SQLite, naming isn’t an issue, but in Postgres unquoted identifiers are automatically lower-cased. If your table was created with upper-case letters or special characters, you need to quote them.
Also, verify that the connection URL is actually targeting the database and schema where your table exists (typically the “public” schema).
Adjusting your table naming or explicitly quoting identifiers should resolve the error.
To spot the difference, you can run the following queries, one at a time, from dbeaver then f…