Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id D6F68632CA4 for ; Sun, 26 Jul 2009 13:18:49 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 55471-06 for ; Sun, 26 Jul 2009 16:18:38 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id 23A98632BC6 for ; Sun, 26 Jul 2009 13:18:39 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id n6QGIb43027957; Sun, 26 Jul 2009 12:18:37 -0400 (EDT) To: Clemens Eisserer cc: pgsql-general@postgresql.org Subject: Re: Implicit sequence with start value? In-reply-to: <194f62550907260910x5a286204g3280e4eb5e583cca@mail.gmail.com> References: <194f62550907260910x5a286204g3280e4eb5e583cca@mail.gmail.com> Comments: In-reply-to Clemens Eisserer message dated "Sun, 26 Jul 2009 12:10:07 -0400" Date: Sun, 26 Jul 2009 12:18:37 -0400 Message-ID: <27956.1248625117@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.073 tagged_above=-10 required=5 tests=AWL=0.073 X-Spam-Level: X-Archive-Number: 200907/1076 X-Sequence-Number: 150839 Clemens Eisserer writes: > Is it possible to use an implicit sequence with a start value? > Something like: CREATE TABLE foo (key SERIAL START 1000 PRIMARY KEY NOT NULL); Well, you can't do it just that way, but you could issue a setval() or ALTER SEQUENCE command after creating the table. For instance regression=# create table foo (bar serial); NOTICE: CREATE TABLE will create implicit sequence "foo_bar_seq" for serial column "foo.bar" CREATE TABLE regression=# alter sequence foo_bar_seq start with 1000; ALTER SEQUENCE or you might prefer regression=# select setval(pg_get_serial_sequence('foo', 'bar'), 1000); setval -------- 1000 (1 row) regards, tom lane