Re: multiple insert into's (may be NEWBIE question) - Mailing list pgsql-general

From Ron Johnson
Subject Re: multiple insert into's (may be NEWBIE question)
Date
Msg-id 1060113580.5258.19.camel@haggis
Whole thread Raw
In response to Re: multiple insert into's (may be NEWBIE question)  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Responses Re: multiple insert into's (may be NEWBIE question)
List pgsql-general
On Tue, 2003-08-05 at 14:42, Stephan Szabo wrote:
> On Tue, 5 Aug 2003, scott.marlowe wrote:
>
> > On Tue, 5 Aug 2003, Williams, Travis L, NPONS wrote:
> >
> > > I have a table (lets say a,text b,text) and I want to insert the data
> > > jim,jimmy and trav,travis can I do this with 1 insert into statement
> > > instead of 2?
> >
> > Not with the current implementation of insert.  There's been some
> > discussion of adding the multiple tuple insert seen in other databases,
> > but I don't think anyone's actually done it or even agreed on exactly how
> > to do it.  I'm not sure if SQL 3 covers this, it seems like it hints at
> > it, but I can't read that stuff all that well most of the time.
> >
> > I don't think there's a way right now though, without using some form of
> > copy.
>
> Well, you can do it with insert ... select and union.
>
> insert into tab
>  select 'jim', 'jimmy'
>   union
>  select 'trav', 'travis';

But the bottom line question is "why do it it in the 1st place?".
Multiple INSERT commands works like a peach, as does COPY from stdin
(thanks again, Jason).

--
+-----------------------------------------------------------------+
| Ron Johnson, Jr.        Home: ron.l.johnson@cox.net             |
| Jefferson, LA  USA                                              |
|                                                                 |
| "I'm not a vegetarian because I love animals, I'm a vegetarian  |
|  because I hate vegetables!"                                    |
|    unknown                                                      |
+-----------------------------------------------------------------+



pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: multiple insert into's (may be NEWBIE question)
Next
From: "Williams, Travis L, NPONS"
Date:
Subject: Re: multiple insert into's (may be NEWBIE question)