Thread: insert multiple rows
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!
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!
On Mon, 2005-10-31 at 17:13, David Fetter wrote: > 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). 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;