Re: SELECT INTO and ON COMMIT

From: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
To: Bruce Momjian <bruce(at)momjian(dot)us>
Cc: Yves Dorfsman <yves(at)zioup(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: SELECT INTO and ON COMMIT
Date: 2015-05-13 23:56:20
Message-ID: CAKFQuwZX_+4A-2iKGo3t-ZPm13GHHCKA5GCqESW0=K1OboyOuA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, May 13, 2015 at 4:38 PM, Bruce Momjian <bruce(at)momjian(dot)us> wrote:

> On Wed, May 13, 2015 at 05:29:36PM -0600, Yves Dorfsman wrote:
> >
> > Is there any way to add an ON COMMIT clause to a SELECT INTO TEMP TABLE?
>
> Well CREATE TABLE has a ON COMMIT { PRESERVE ROWS | DELETE ROWS | DROP }
> clause, but I don't see it in SELECT INTO, so it seems you have to
> create the temp table using CREATE TABLE, then INSERT ... SELECT.
>
>
​From the documentation of SELECT INTO

"​
The PostgreSQL usage of SELECT INTO to represent table creation is
historical. It is best to use CREATE TABLE AS for this purpose in new code.
​"​

http://www.postgresql.org/docs/9.4/interactive/sql-createtableas.html

​Which effectively means consider the feature deprecated. Especially since
CREATE TABLE is standard conforming and SELECT INTO is not.

Given this I'm not sure why we bothered to add "UNLOGGED" to SELECT INTO
back in 9.1 ...

David J.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Yves Dorfsman 2015-05-14 00:05:43 Re: SELECT INTO and ON COMMIT
Previous Message Bruce Momjian 2015-05-13 23:38:29 Re: SELECT INTO and ON COMMIT