Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id CE6661337B34 for ; Tue, 1 Mar 2011 16:29:54 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 99511-02 for ; Tue, 1 Mar 2011 20:29:47 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by mail.postgresql.org (Postfix) with ESMTP id 4119A1336971 for ; Tue, 1 Mar 2011 16:29:46 -0400 (AST) Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by mail.archonet.com (Postfix) with ESMTP id 8AA107C140; Tue, 1 Mar 2011 20:29:43 +0000 (GMT) Message-ID: <4D6D5737.3030208@archonet.com> Date: Tue, 01 Mar 2011 20:29:43 +0000 From: Richard Huxton User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.15pre) Gecko/20110202 Lightning/1.0b2 Shredder/3.1.9pre MIME-Version: 1.0 To: Jacques Lebrun CC: pgsql-sql@postgresql.org Subject: Re: Problem with serial counters References: <7AD8C28EFB264E22BB784F83949DF0D2@Cplus.int> In-Reply-To: <7AD8C28EFB264E22BB784F83949DF0D2@Cplus.int> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.918 tagged_above=-5 required=5 tests=BAYES_00=-1.9, RDNS_DYNAMIC=0.982 X-Spam-Level: X-Archive-Number: 201103/4 X-Sequence-Number: 35206 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