Re: Problem with serial counters

From: Richard Huxton <dev(at)archonet(dot)com>
To: Jacques Lebrun <jlebrun(at)cplus(dot)org>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Problem with serial counters
Date: 2011-03-01 20:29:43
Message-ID: 4D6D5737.3030208@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message S G 2011-03-01 22:13:29 Re: distinguishing identical columns after joins
Previous Message Rob Sargent 2011-03-01 19:53:38 Re: distinguishing identical columns after joins