Re: customising serial type - Mailing list pgsql-sql

From Michael Glaesemann
Subject Re: customising serial type
Date
Msg-id 0352BD99-B517-4D57-808A-924A2D59ADFF@myrealbox.com
Whole thread Raw
In response to customising serial type  (Kenneth Gonsalves <lawgon@thenilgiris.com>)
List 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


pgsql-sql by date:

Previous
From: Krasimir Dimitrov
Date:
Subject: Re: customising serial type
Next
From: Veikko Mäkinen
Date:
Subject: Alias to a type