pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Richard Huxton <dev@archonet.com>
To: Jacques Lebrun <jlebrun@cplus.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: Problem with serial counters
Date: Tue, 01 Mar 2011 20:29:43 +0000
Message-ID: <4D6D5737.3030208@archonet.com> (raw)
In-Reply-To: <7AD8C28EFB264E22BB784F83949DF0D2@Cplus.int>
References: <7AD8C28EFB264E22BB784F83949DF0D2@Cplus.int>

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



view thread (3+ messages)

Message-ID: <4D6D5737.3030208@archonet.com>
Permalink:  ../4D6D5737.3030208@archonet.com/
Also on:    postgresql.org/message-id/4D6D5737.3030208@archonet.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dev@archonet.com, jlebrun@cplus.org
  Subject: Re: Problem with serial counters
  In-Reply-To: <4D6D5737.3030208@archonet.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox