Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Rainer Weikusat Newsgroups: comp.databases.postgresql Subject: Re: Why does this third line work, and the first two not? Date: Thu, 27 Apr 2017 20:10:35 +0100 Lines: 44 Message-ID: <877f25y8d0.fsf@doppelsaurus.mobileactivedefense.com> References: <59023252$0$785$e4fe514c@news.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: individual.net HPhKV0ucXX9bpiA2mLQaDQwPedGP4vC+PNMFdmfdo06Xc4wjY= Cancel-Lock: sha1:OxifhxGn5xmpg+LH04rOxiCS8Zo= sha1:mCOQM48v/kduvKgHV2iOEj38n8s= User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) Xref: csiph.com comp.databases.postgresql:744 Luuk writes: > Why does this third line work, and the first two not? > > abcd=# select RequestMessageId from table_details; > ERROR: column "requestmessageid" does not exist > LINE 1: select RequestMessageId from table_details; > ^ > HINT: Perhaps you meant to reference the column > "table_details.RequestMessageId". > > abcd=# select a.RequestMessageId from table_details a; > ERROR: column a.requestmessageid does not exist > LINE 1: select a.RequestMessageId from table_details a; > ^ > HINT: Perhaps you meant to reference the column "a.RequestMessageId". > > abcd=# select a."RequestMessageId" from table_details a; > RequestMessageId > ------------------ > (0 rows) That's because unquoted SQL identifiers are not case-sensitive. If the really uses a mixed-case name, accessing it requires a quoted identifier, cf mad_database=# create table blubb ("Fump" varchar); CREATE TABLE mad_database=# select Fump from blubb; ERROR: column "fump" does not exist LINE 1: select Fump from blubb; ^ mad_database=# select "Fump" from blubb; Fump ------ (0 rows) mad_database=# drop table blubb; DROP TABLE mad_database=# create table blubb (Fump varchar); CREATE TABLE mad_database=# select fUMP from blubb; fump ------ (0 rows)