Dipen
Dipen

Reputation: 546

Why doesn't postgres recognize my table fields?

I realize that this question has been answered before, specificaly in this post; however, the solution does not work in my case. I can successfully access my database and table through the "/d" command in the psql commandline utility. But I am recieving a "Did not find any relation named" error, when attempting to examine a field value named question in my table.

enter image description here

Why is psql not recognizing the existence of the question field?

Upvotes: 1

Views: 1387

Answers (2)

Vivek S.
Vivek S.

Reputation: 21915

Why doesn't postgres recognize my table fields?

Do not blame PostgreSQL, because the fault is your's.You dint understood psql commands commands correctly.

Did not find the any relation named "question"

Yes, PostgreSQL said correctly.

in PostgreSQL realtions are tables,views,sequences,index but a column is not a relation

  • Use \d to lists all the RELATIONS(tables,views,sequences,index) in your database.

In your case \d post(post is a table(note: a relation)) will returns table's structure, But \d question is WRONG (because question is not a relation,it's a column),So you must use SELECT.

i.e SELECT question FROM post

List Of `\d` commands
----------------------
\dt  - Tables
\dv  - View
\di  - Index
\df  - function

Learn more @ http://www.faqs.org/docs/ppbook/c4890.htm

Upvotes: 3

Kokizzu
Kokizzu

Reputation: 26888

The question column is not a table, view, sequence, or index name, so it won't appear when called using \d..

What you should do is SELECT question FROM post;

Upvotes: 1

Related Questions