SQL gotcha

From: "Dean Gibson (DB Administrator)" <postgresql(at)ultimeth(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: SQL gotcha
Date: 2011-02-14 23:29:25
Message-ID: 4D59BAD5.4090306@ultimeth.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

As you all know, when you specify an alias for a table or column name,
the keyword "AS" is usually optional. I personally like to always
include the "AS" keyword, if for no other reason than readability, and I
presume that always using "AS" might catch some syntactic errors as well.

However, recently I ran across a statement where the optionality of the
"AS" keyword caused me some grief:

SELECT ... FROM aaa LEFFT JOIN bbb WHERE ...

Note the (unintentional) misspelling of the keyword "LEFT". PostgreSQL
took "LEFFT" to be an alias for table "aaa" and silently accepted the
statement; naturally I did not get the results I expected !!

If PostgreSQL had an option to always require the "AS", that would have
caught this error. Is there any interest in PostgreSQL having any
"pedantic"-type options, like many C/C++ compilers do?

--
Mail to my list address MUST be sent via the mailing list.
All other mail to my list address will bounce.

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Achilleas Mantzios 2011-02-15 07:41:11 Re: SQL gotcha
Previous Message Gavin Beau Baumanis 2011-02-13 11:08:41 Re: UTF characters compromising data import.