Re: SELECT INTO deprecation

Peter Eisentraut <peter.eisentraut@enterprisedb.com>

From: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Paquier <michael@paquier.xyz>, Stephen Frost <sfrost@snowman.net>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2020-12-03T19:26:59Z
Lists: pgsql-hackers
On 2020-12-03 16:34, Tom Lane wrote:
> As I recall, a whole lot of the pain we have with INTO has to do
> with the semantics we've chosen for INTO in a set-operation nest.
> We think you can write something like
> 
>     SELECT ... INTO foo FROM ... UNION SELECT ... FROM ...
> 
> but we insist on the INTO being in the first component SELECT.
> I'd like to know exactly how much of that messiness is shared
> by SQL Server.

On sqlfiddle.com, this works:

select a into t3 from t1 union select a from t2;

but this gets an error:

select a from t1 union select a into t4 from t2;

SELECT INTO must be the first query in a statement containing a UNION, 
INTERSECT or EXCEPT operator.



Commits

  1. doc: Clarify status of SELECT INTO on reference page

  2. Remove gratuitous uses of deprecated SELECT INTO