Re: store multiple rows with the SELECT INTO statement

From: Kevin Grittner <kgrittn(at)ymail(dot)com>
To: Janek Sendrowski <janek12(at)web(dot)de>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: store multiple rows with the SELECT INTO statement
Date: 2013-09-03 21:07:26
Message-ID: 1378242446.61431.YahooMailNeo@web162903.mail.bf1.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Janek Sendrowski <janek12(at)web(dot)de> wrote:

> I just can't understabd why it's not possible to store multiple
> columns returning from a dynamic Select statement which is
> executet with EXECUTE into a temporary table.

You can:

CREATE TEMPORARY TABLE AS SELECT ...

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

As the Notes section says:

| This command is functionally similar to SELECT INTO, but it is
| preferred since it is less likely to be confused with other uses
| of the SELECT INTO syntax. Furthermore, CREATE TABLE AS offers a
| superset of the functionality offered by SELECT INTO.

Also see this:

http://www.postgresql.org/docs/current/interactive/plpgsql-statements.html#PLPGSQL-STATEMENTS-ASSIGNMENT

| Tip: Note that this interpretation of SELECT with INTO is quite
| different from PostgreSQL's regular SELECT INTO command, wherein
| the INTO target is a newly created table. If you want to create a
| table from a SELECT result inside a PL/pgSQL function, use the
| syntax CREATE TABLE ... AS SELECT.

--
Kevin Grittner
EDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2013-09-03 21:30:18 Re: ALTER TABLE transaction isolation problem
Previous Message Martin Renters 2013-09-03 20:41:53 uuids with btree_gist