Re: SQL INSERT Statement -- Multi-Row Insert - Mailing list pgsql-novice

From Bruno Wolff III
Subject Re: SQL INSERT Statement -- Multi-Row Insert
Date
Msg-id 20030614141117.GA28264@wolff.to
Whole thread Raw
In response to SQL INSERT Statement -- Multi-Row Insert  (Alan Searles <alien@attglobal.net>)
Responses Re: SQL INSERT Statement -- Multi-Row Insert  (Bruno Wolff III <bruno@wolff.to>)
Re: SQL INSERT Statement -- Multi-Row Insert  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-novice
On Sat, Jun 14, 2003 at 09:52:26 -0400,
  Alan Searles <alien@attglobal.net> wrote:
>   Is PostgreSQL able to perform multi-row inserts using a single INSERT
> statement as shown below ?
>
> INSERT INTO table ( col1, col2, col3 )
>        VALUES  ( value1, value2, value3 ),
>                ( value4, value5, value6 ),
>                ( value7, value8, value9 )
>
>    Yes, I have looked through the PostgreSQL documentation, and it DOES
> NOT appear as though it can.
>    I was hoping that I did not read it right.

This was recently covered on one of the postgres lists. For small
(I am not sure how long query strings can be, but small is at least
hundreds of values.) numbers of values you can use union. For example:

INSERT INTO table ( col1, col2, col3 )
  select value1, value2, value3 union
  select value4, value5, value6 union
  select value7, value8, value9;

pgsql-novice by date:

Previous
From: Alan Searles
Date:
Subject: SQL INSERT Statement -- Multi-Row Insert
Next
From: Bruno Wolff III
Date:
Subject: Re: SQL INSERT Statement -- Multi-Row Insert