Reputation: 4003
I am doing a select * on a postgresql table, and everything looks good. But if I do:
SELECT Name from People
It says:
ERROR: column People.Name does not exist
SQL state: 42703
Character: 8
But the name column shows up during select *. I've tried:
SELECT People.Name from People
as well, with the same result. Am I missing something? It should be pretty easy to do this in any other database.
Upvotes: 3
Views: 1749
Reputation: 3484
PostgreSQL converts everything to lowercase.
If you asks for this:
CREATE TABLE People
{
id SERIAL,
Att1 varchar(100)
-- constraints
};
SELECT Name FROM People;
You should get all the information, because pgsql converts this to
CREATE TABLE people
{
id SERIAL,
att1 varchar(100),
-- constraints
};
SELECT name FROM people;
If you built your table with pgAdmin and created field with mixed casing, you will need to quote them to be sucessfull, like this:
SELECT "Att1" FROM people
Upvotes: 2
Reputation: 39485
Name
is a keyword, so it might not be handled well in this case. The best thing to do would be to alias the table like this:
SELECT Name from People
p
and then use the p
to select the column:
SELECT
p.Name
from People p
Upvotes: 1