Queries in Postgres fail with ERROR: relation "<tablename>" does not exist

Still need help?

The Atlassian Community is here for you.

Ask the community

Summary

When manually running queries against Jira database in Postgres, user is informed that the table does not exist.

Environment

  • Jira Server or DC
  • Postgres database

Diagnosis

When manually running queries against Jira database in Postgres, user is informed that the table does not exist. 

For example:

jiradb=# select * from cwd_user;
ERROR:  relation "cwd_user" does not exist
LINE 1: select * from cwd_user;

We can confirm that the table is present by running the following query:

jiradb=# \dt
                      List of relations

 Schema |              Name              | Type  |   Owner    

--------+--------------------------------+-------+------------

 jira     | cwd_synchronisation_status     | table | jiradbuser

 jira     | cwd_synchronisation_token      | table | jiradbuser

 jira     | cwd_user                       | table | jiradbuser

 jira     | cwd_user_attributes            | table | jiradbuser

Cause

In this case, the query is failing because the database was created with a custom schema name called "jira".

The default schema in postgres is "public", so, when you leave the schema name out of your sql, it will try to search for the table as public.cwd_user.


Solution

You must change your sql, so it includes the schema name in your query, <schema>.<table_name>:

Example:

jiradb=# select * from jira.cwd_user;
Last modified on Sep 28, 2022

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.