Thread: insert multiple rows

insert multiple rows

From
"G"
Date:
Hello,

Just getting started with postgres. Is there an equivalent sql command to
insert multiple rows? In mysql it's:

insert into table (a,b,c)
values (1,2,3), (4,5,6);

I exported 6000 rows from mysql using single inserts - it's rather slow
executing them one by one into progresql.

Thanks,
Gerard


Re: insert multiple rows

From
Andrew McMillan
Date:
On Sun, 2002-05-05 at 10:31, G wrote:
>
> Hello,
>
> Just getting started with postgres. Is there an equivalent sql command to
> insert multiple rows? In mysql it's:
>
> insert into table (a,b,c)
> values (1,2,3), (4,5,6);
>
> I exported 6000 rows from mysql using single inserts - it's rather slow
> executing them one by one into progresql.

In PostgreSQL you should:

BEGIN WORK;
INSERT .....
...
COMMIT;

To have it all happen much quicker.

There is not equivalent syntax to the non-standard-SQL of MySQL within
the SQL standard, nor does PostgreSQL have such an extension.

If you can get the data in tab-delimited format you could also use the
COPY command in PostgreSQL to load the data much faster.

Regards,
                    Andrew.
--
--------------------------------------------------------------------
Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington
WEB: http://catalyst.net.nz/        PHYS: Level 2, 150-154 Willis St
DDI: +64(4)916-7201    MOB: +64(21)635-694    OFFICE: +64(4)499-2267
       Are you enrolled at http://schoolreunions.co.nz/ yet?


Altering columns without losing data

From
"G"
Date:
Hello,

Is there a way to change a column's data type without removing and adding it
(and losing data)? Such as changing the text length for a column.

Thanks,
Gerard



Re: Altering columns without losing data

From
AarniRuuhimäki / Megative Tmi / KYMI.com
Date:
Hi !

Not sure if this is the right way, but I've done this succesfully by dumping
(pg_dump -c) the db, then drop the db, edit the dump file's CREATE TABLE
commands to change datatype or length, then restore the db with the dump.

Be careful and make sure you have the dump file somewhere safe.

BR,

aarni


On Thursday 09 May 2002 09:11 pm, you wrote:
> Hello,
>
> Is there a way to change a column's data type without removing and adding
> it (and losing data)? Such as changing the text length for a column.
>
> Thanks,
> Gerard
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)