Skip site navigation (1) Skip section navigation (2)

Re: insert retrieved data into a new table

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: insert retrieved data into a new table
Date: 2011-04-24 21:13:33
Message-ID: ip23pe$ret$1@dough.gmane.org (view raw or flat)
Thread:
Lists: pgsql-novice
e-letter wrote on 24.04.2011 22:52:
> Readers,
>
> Is it possible to use the result of a SELECT function to populate a
> new table? The objective is to write the new table for use by gnuplot.
>
> The SELECT function features a mathematical operator such as SUM which
> obtains a value. Is it possible to use the value from this function to
> be entered into the new table. Please advise the relevant parts of the
> documentation to read.
>

CREATE TABLE new_table
AS
SELECT col1, col2, col3
FROM some_table
WHERE ...

This is the syntax I always use, but I have just realized that it not documented in the manual...


Or using SELECT INTO:
http://www.postgresql.org/docs/current/static/sql-selectinto.html

SELECTcol1, col2, col3
   INTO new_table
FROM some_table
WHERE ...

Thomas


In response to

Responses

pgsql-novice by date

Next:From: Tom LaneDate: 2011-04-24 21:19:10
Subject: Re: insert retrieved data into a new table
Previous:From: e-letterDate: 2011-04-24 20:52:32
Subject: insert retrieved data into a new table

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group