A table with capital letters cannot be found in PostgreSQL
Why PostgreSQL does not like uppercase table namesShort answer
PostgreSQL folds unquoted names to lower case. A table created as "Users" with double quotes keeps its capital letter, so a query for Users or users looks for a different name. Quote the name exactly every time, or rename the table and columns to lower case so no quotes are needed.
Fix it fast
1Find out which cause you have
List tables and see how the name is spelled. A capital letter in the list means the name was created quoted.
\dt2Match what you see, then jump to its fix
What does the error look like?
Why PostgreSQL does not like uppercase table namesA query works only when the table name is in double quotes
Cause 1 of 3
The table was created with a quoted mixed-case name
1Check
Quoting an identifier makes it case-sensitive, while unquoted names are folded to lower case. FOO, foo and "foo" are the same name; "Foo" and "FOO" are different ones.
\dt2Fix
Use the double-quoted name exactly as it was created.
SELECT * FROM "Users";3Verify
The query returns rows.
SELECT count(*) FROM "Users";Confirmed by postgresql.org
Cause 2 of 3
Columns were created quoted as well
1Check
The same folding rule applies to column names, so a column created as "firstName" must be quoted in every query.
\d "Users"2Fix
Quote the column in each query, or rename it to a lower-case name.
SELECT "firstName" FROM "Users";3Verify
The column is returned.
SELECT "firstName" FROM "Users" LIMIT 1;Confirmed by postgresql.org
Cause 3 of 3
You want to stop quoting for good
1Check
The manual advises to always quote a particular name or never quote it. Renaming to lower case lets plain names work.
\dt2Fix
Rename the table and columns once.
ALTER TABLE "Users" RENAME TO users;
ALTER TABLE users RENAME COLUMN "firstName" TO first_name;3Verify
An unquoted query now works.
SELECT first_name FROM users LIMIT 1;Confirmed by postgresql.org
How do I stop it coming back?
- Create tables and columns in lower case with underscores, unquoted.
- Check what names your ORM or migration tool generates; some quote them.
- Never mix quoted and unquoted styles in one database.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Related fixes
Databases
DBeaver cannot run pg_restore: the utility is not found in the client home
Utility 'pg_restore' not found in client home '/usr/lib' (/usr/lib)
DBeaver runs pg_restore from a local PostgreSQL client folder; it does not bundle one.
3 causes, each with a fixDatabases
DBeaver cannot download the PostgreSQL driver from Maven
The PostgreSQL driver files are missing and the download does not complete
DBeaver downloads the PostgreSQL JDBC driver from a Maven repository the first time you connect.
3 causes, each with a fixDatabases
python manage.py migrate finishes but the tables for my app are missing
relation "myapp_book" does not exist
migrate only applies migration files that exist.
3 causes, each with a fixDatabases
Django save fails on PostgreSQL: null value in a column violates a not-null constraint
django.db.utils.IntegrityError: null value in column "price" of relation "shop_product" violates not-null constraint
A model field is NOT NULL in the database unless it has null=True.
3 causes, each with a fixDatabases
Django migration on PostgreSQL stops with 'pending trigger events'
django.db.utils.OperationalError: cannot ALTER TABLE "mytable" because it has pending trigger events
PostgreSQL runs a Django migration in one transaction.
2 causes, each with a fixDatabases
Django cannot connect to PostgreSQL: connection refused on port 5432, locally or in Docker
Is the server running on that host and accepting TCP/IP connections?
Connection refused means nothing accepted the connection at the host and port Django used.
4 causes, each with a fix