Search code examples
postgresqlpgadmin

pgAdmin error - relation "[name of function/Views/Trigger Functions]" does not exist


I'm just new to pgAdmin, so I don't really know what causes these errors:

ERROR:  relation "ongoingprojects" does not exist
LINE 1: SELECT * FROM ongoingProjects;
                      ^

********** Error **********

ERROR: relation "ongoingprojects" does not exist
SQL state: 42P01
Character: 15

Even if the function/view exists in the schema. Why does it give that error? And what should I do to fix it?


Solution

  • Pay careful attention to the error message:

    ERROR: relation "ongoingprojects" does not exist
    

    Note that it is complaining about ongoingprojects when your SQL talks about ongoingProjects. You probably created the table with something like:

    create table "ongoingProjects" ( ...
    

    PostgreSQL folds all identifiers (table names, column names, ...) to lower case unless they are double quoted. Once you've created the table as "ongoingProjects", you'll have to double quote the name everywhere and exactly match that case:

    select * from "ongoingProjects";
    

    The usual practice with PostgreSQL is to create tables with unquoted names in lower case with word separated using underscores:

    create table ongoing_projects ( ...
    

    so that you don't have worry about quoting.

    Here is the link to the relevant part of the manual