Re: Problem with serial counters - Mailing list pgsql-sql

From Richard Huxton
Subject Re: Problem with serial counters
Date
Msg-id 4D6D5737.3030208@archonet.com
Whole thread Raw
In response to Problem with serial counters  ("Jacques Lebrun" <jlebrun@cplus.org>)
List pgsql-sql
On 24/02/11 21:09, Jacques Lebrun wrote:
> I guess when I do an insert with all the fields (including the RowId),
> Postgres does not increment the serial counter.
> I cannot remove the RowId field from the Insert of my setup script
> because this setup script is also used by customers using MySQL.

Apart from Vibhor's suggestion (which is the typical way PG does it) you 
can also set the auto field to DEFAULT:

INSERT INTO mytable (rowid, other) VALUES (DEFAULT,'a'), (DEFAULT,'b');

This should work on either system.

--   Richard Huxton  Archonet Ltd


pgsql-sql by date:

Previous
From: Rob Sargent
Date:
Subject: Re: distinguishing identical columns after joins
Next
From: S G
Date:
Subject: Re: distinguishing identical columns after joins