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

非 Y 不嫁゛ 提交于 2019-12-30 10:26:02

问题


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?


回答1:


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




回答2:


For me the issue was having a schema named differently than the database.

Two solutions:

1) Modify schema name to match db name

or

2) Prepend table in query with schema name, eg: SELECT * FROM my_schema.ongoingProjects;



来源:https://stackoverflow.com/questions/19128870/pgadmin-error-relation-name-of-function-views-trigger-functions-does-not-e

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!