Re: Column names for INSERT with query - Mailing list pgsql-general

From BladeOfLight16
Subject Re: Column names for INSERT with query
Date
Msg-id CA+=1U=VmT8KjEhfgHkxdgJuckmcyLfsEAerC_cSWqAo7UY=P2g@mail.gmail.com
Whole thread Raw
In response to Re: Column names for INSERT with query  (Ian Lawrence Barwick <barwick@gmail.com>)
List pgsql-general
On Thu, Aug 22, 2013 at 6:36 PM, Ian Lawrence Barwick <barwick@gmail.com> wrote:
INSERT INTO t (t_field1, t_field2, t_field3)
  SELECT r.field1, r.field2, (x+y)
    FROM r

Obligatory link to documentation: http://www.postgresql.org/docs/9.2/static/sql-insert.html. See where it says [ ( column_name [, ...] ) ]? The square brackets mean "optional", and the ",..." means repeat as needed. The fact "column_name" is italics tell you it's some kind of variable text you should replace, and later on in the page explains what goes there. So it's telling you that you can use a comma separated list of column names from the destination table. PostgreSQL has some of the best documentation of any software I've ever seen. Don't hesitate to check it often when working.

pgsql-general by date:

Previous
From: Michael Paquier
Date:
Subject: Re: Temp files on Commit
Next
From: Vincent Veyron
Date:
Subject: Re: Locale Issue