Home > Archive > PostgreSQL Discussion > October 2005 > insert multiple rows









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author insert multiple rows
blackwater dev

2005-10-31, 8:24 pm

In MySQL, I can insert multiple rows like this:

insert into cars values(5, "toyota"),(5,"ford"), etc.

How can I do something similiar in PostgreSQL?

Thanks!

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

http://archives.postgresql.org

David Fetter

2005-10-31, 8:24 pm

On Mon, Oct 31, 2005 at 06:06:14PM -0500, blackwater dev wrote:
> In MySQL, I can insert multiple rows like this:
>
> insert into cars values(5, "toyota"),(5,"ford"), etc.
>
> How can I do something similiar in PostgreSQL?


The similar thing in PostgreSQL is the COPY command (man 8 copy).

HTH :)

Cheers,
David.
--
David Fetter david@fetter.org http://fetter.org/
phone: +1 510 893 6100 mobile: +1 415 235 3778

Remember to vote!

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

http://archives.postgresql.org

Scott Marlowe

2005-10-31, 8:24 pm

On Mon, 2005-10-31 at 17:13, David Fetter wrote:
> On Mon, Oct 31, 2005 at 06:06:14PM -0500, blackwater dev wrote:
>
> The similar thing in PostgreSQL is the COPY command (man 8 copy).


Note that for complex schemas, prepared queries may also be a good
choice.

Symantically, the closest thing to this for postgresql is doing:

begin;
insert ...
insert ...
insert ...
commit;


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

http://archives.postgresql.org

Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com