dbTalk Databases Forums  

inserting multiple rows

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss inserting multiple rows in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Si Chen
 
Posts: n/a

Default inserting multiple rows - 08-02-2004 , 01:26 PM






Does PostgreSQL not support

insert into mytable (row1, row2) values ('a', '1'), ('b', '2'), ('c',
'3'), ('d', '4')

? If not, does anyone know why not?

Si


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
  #2  
Old   
Rafael Charnovscki
 
Posts: n/a

Default Re: inserting multiple rows - 08-03-2004 , 09:18 AM






According to the 7.4.3 documentation it's not possible
to insert more than one row with INSERT. See
http://www.postgresql.org/docs/curre...ql-insert.html

I think this is not a PGSQL issue, since SQL standard defines
INSERT command to insert one row at a time.

There are alternatives to insert multiple rows using a SELECT or a COPY.

http://www.postgresql.org/docs/curre.../sql-copy.html

http://pgsqld.active-venture.com/tutorial-populate.html

These links may help too:

http://archives.postgresql.org/pgsql...3/msg00076.php

http://archives.postgresql.org/pgsql...5/msg00047.php

http://www.faqs.org/docs/ppbook/r27281.htm

Regards,
Rafael Charnovscki

Si Chen wrote:
Quote:
Does PostgreSQL not support

insert into mytable (row1, row2) values ('a', '1'), ('b', '2'), ('c',
'3'), ('d', '4')

? If not, does anyone know why not?
Si


---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html



Reply With Quote
  #3  
Old   
Tony Reina
 
Posts: n/a

Default Re: inserting multiple rows - 08-06-2004 , 09:27 AM



schen (AT) graciousstyle (DOT) com (Si Chen) wrote in message news:<410E875B.8050005 (AT) graciousstyle (DOT) com>...
Quote:
Does PostgreSQL not support

insert into mytable (row1, row2) values ('a', '1'), ('b', '2'), ('c',
'3'), ('d', '4')

No, but the COPY command can do something like this.

COPY INTO mytable FROM stdout;
a b c d
1 2 3 4



Take a look at http://www.postgresql.org/docs/7.4/static/sql-copy.html


-Tony


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.