Re: How to run queries without double quotes on tables and columns - Mailing list pgsql-novice

From Tom Lane
Subject Re: How to run queries without double quotes on tables and columns
Date
Msg-id 26107.1255228963@sss.pgh.pa.us
Whole thread Raw
In response to How to run queries without double quotes on tables and columns  (Susan M Farley <sfarley1@gmu.edu>)
Responses Re: How to run queries without double quotes on tables and columns  (Thomas Kellerer <spam_eater@gmx.net>)
List pgsql-novice
Susan M Farley <sfarley1@gmu.edu> writes:
> Sorry, I'm really new to PostgreSQL and am used to Oracle. In function and in regular queries, I usually have to have
doublequotes (") around the names of columns and table names. Otherwise, I get an error that the schema, table, or
columndoesn't exist. I don't always have to though. Sometimes the function works just fine without them even though I
amworking with the same table and schema. What am I doing wrong? 

Names that aren't double-quoted will be folded to lower case.  If the
name you've got stored is mixed case or all upper case, you'd have to
quote to get a match.  See
http://www.postgresql.org/docs/8.4/static/sql-syntax-lexical.html#SQL-SYNTAX-IDENTIFIERS

particularly the last para under 4.1.1:

Quoting an identifier also makes it case-sensitive, whereas unquoted
names are always folded to lower case. For example, the identifiers FOO,
foo, and "foo" are considered the same by PostgreSQL, but "Foo" and
"FOO" are different from these three and each other. (The folding of
unquoted names to lower case in PostgreSQL is incompatible with the SQL
standard, which says that unquoted names should be folded to upper
case. Thus, foo should be equivalent to "FOO" not "foo" according to the
standard. If you want to write portable applications you are advised to
always quote a particular name or never quote it.)

I don't know whether Oracle is exactly standards-compliant on this
point, or has yet another behavior.

            regards, tom lane

pgsql-novice by date:

Previous
From: Thom Brown
Date:
Subject: Re: How to run queries without double quotes on tables and columns
Next
From: Thomas Kellerer
Date:
Subject: Re: How to run queries without double quotes on tables and columns