Re: SQL WHERE: many sql or large IN()

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: tom <tom(at)tacocat(dot)net>
Cc: Postgresql <pgsql-general(at)postgresql(dot)org>
Subject: Re: SQL WHERE: many sql or large IN()
Date: 2007-04-06 19:33:48
Message-ID: 16762.1175888028@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

tom <tom(at)tacocat(dot)net> writes:
> I've never seen this before.
> Is this PG specific or generic SQL that I've never been exposed to?

It's in the SQL standard. SQL92 saith

<table value constructor> ::=
VALUES <table value constructor list>

<table value constructor list> ::=
<row value constructor> [ { <comma> <row value constructor> }... ]

and lists this as an alternative to <query specification> (ie, a SELECT)
in the query grammar. So you can write VALUES anywhere you could write
SELECT. However, the spec also allows "entry level SQL" implementations
to dumb it down pretty far:

1) The following restrictions apply for Intermediate SQL:

a) A <table value constructor> shall contain exactly one <row
value constructor> that shall be of the form "(<row value
constructor list>)".

b) A <table value constructor> shall be the <query expression>
of an <insert statement>.

2) The following restrictions apply for Entry SQL in addition to
any Intermediate SQL restrictions:

None.

What we had up to 8.2 was the entry-level definition. I couldn't tell
you which other DBMSes support the full definition...

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Harpreet Dhaliwal 2007-04-06 19:51:03 reindexing keys in postgres
Previous Message Listmail 2007-04-06 19:02:59 Re: SQL WHERE: many sql or large IN()