Обсуждение: Why are quotes required around table / column names in SQL statements?

Поиск
Список
Период
Сортировка

Why are quotes required around table / column names in SQL statements?

От
"Wade Burlingame"
Дата:
...and is there any way I can get rid of this requirement?  I'm just getting
into PGSQL and I find the quotes very distracting.





Re: Why are quotes required around table / column names in SQL statements?

От
missive@frontiernet.net (Lee Harr)
Дата:
On Mon, 02 Apr 2001 08:56:16 GMT, Wade Burlingame <bad@dog.bad> wrote:
>
>...and is there any way I can get rid of this requirement?  I'm just getting
>into PGSQL and I find the quotes very distracting.


I never use quotes on table or column names.

I think you only need them if you want to have capitalization
be significant to the name. Normally (with no quotes)
table == Table == TaBlE == TABLE

Quotes also allow you to use spaces in names.

Like I said, I never use this feature.

Re: Why are quotes required around table / column names in SQL statements?

От
Joel Burton
Дата:
On Mon, 2 Apr 2001, Wade Burlingame wrote:

> ...and is there any way I can get rid of this requirement?  I'm just getting
> into PGSQL and I find the quotes very distracting.

The quotes are only *needed* around tables/columns/etc if they contain
characters not in the alphanumeric set, or if it conflicts with a reserved
word.

So, one can say

  CREATE TABLE foo

but must use quotes for

  CREATE TABLE "foo is the word"

or

  CREATE TABLE "table"

or such.

The only time you normally see them (if you haven't used them) is w/tools
like pg_dump. And there's a command-line switch to not show them if not
neccssary, IIRC.


HTH,
--
Joel Burton   <jburton@scw.org>
Director of Information Systems, Support Center of Washington


Re: Why are quotes required around table / column names in SQL statements?

От
Doug McNaught
Дата:
"Wade Burlingame" <bad@dog.bad> writes:

> ...and is there any way I can get rid of this requirement?  I'm just getting
> into PGSQL and I find the quotes very distracting.

They're not required, unless you want to treat the table and column
names in a case-sensitive manner (which is not generally done).  The
SQL standard is case-insensitive I believe.

-Doug