Re: SQL INSERT Statement -- Multi-Row Insert

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Alan Searles <alien(at)attglobal(dot)net>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: SQL INSERT Statement -- Multi-Row Insert
Date: 2003-06-14 14:11:17
Message-ID: 20030614141117.GA28264@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

On Sat, Jun 14, 2003 at 09:52:26 -0400,
Alan Searles <alien(at)attglobal(dot)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;

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Bruno Wolff III 2003-06-14 17:11:23 Re: SQL INSERT Statement -- Multi-Row Insert
Previous Message Alan Searles 2003-06-14 13:52:26 SQL INSERT Statement -- Multi-Row Insert