Re: SQL WHERE: many sql or large IN() - Mailing list pgsql-general

From Tom Lane
Subject Re: SQL WHERE: many sql or large IN()
Date
Msg-id 16762.1175888028@sss.pgh.pa.us
Whole thread Raw
In response to Re: SQL WHERE: many sql or large IN()  (tom <tom@tacocat.net>)
List pgsql-general
tom <tom@tacocat.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

pgsql-general by date:

Previous
From: Listmail
Date:
Subject: Re: SQL WHERE: many sql or large IN()
Next
From: "Harpreet Dhaliwal"
Date:
Subject: reindexing keys in postgres