Re: customising serial type

From: Michael Glaesemann <grzm(at)myrealbox(dot)com>
To: Kenneth Gonsalves <lawgon(at)thenilgiris(dot)com>
Cc: PostgreSQL SQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: customising serial type
Date: 2005-06-21 10:23:57
Message-ID: 0352BD99-B517-4D57-808A-924A2D59ADFF@myrealbox.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Jun 21, 2005, at 7:01 PM, Kenneth Gonsalves wrote:

> in a table with a serial datatype, how do i get the sequence to start
> at a specific number like 100000?

The SERIAL datatype (e.g., CREATE TABLE foo(foo_id SERIAL) )is a
shorthand for something like
CREATE SEQUENCE foo_id_seq;
CREATE TABLE foo (foo_id integer default nextval('foo_id_seq') );

If you want it to specify the start value, you'll need to either use
CREATE SEQUENCE first and then create the table with the appropriate
default, or use ALTER SEQUENCE after creating the table.

http://www.postgresql.org/docs/8.0/interactive/sql-createsequence.html
http://www.postgresql.org/docs/8.0/interactive/sql-altersequence.html

Michael Glaesemann
grzm myrealbox com

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message MRB 2005-06-21 15:20:19 ENUM like data type
Previous Message Krasimir Dimitrov 2005-06-21 10:07:57 Re: customising serial type