Re: CREATE TABLE initial value for PRIMARY KEY

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: Maurice Yarrow <yarrow(at)best(dot)com>
Cc: General PostgreSQL List <pgsql-general(at)postgresql(dot)org>
Subject: Re: CREATE TABLE initial value for PRIMARY KEY
Date: 2006-10-27 20:34:24
Message-ID: 13265.79301.qm@web31810.mail.mud.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> I thought about using a DEFAULT value, but I had presumed
> that this was only for repeated intializations. So then is it the
> case that a
> CREATE TABLE mytable ( id INTEGER PRIMARY KEY DEFAULT 100000, ...
> only applies this default to the very first row of such a table, and then
> sensibly, increments from there ?
> (Guess I could easily try this out...)

Ah, I think I know what you are looking for. You want an auto-incrementing number. There are
special sudo-data-types called serial bigserial. These are really auto-incrementing
integers/bigintegers. For more details on how to use this see:

http://www.postgresql.org/docs/8.1/interactive/datatype.html#DATATYPE-SERIAL

Also, when relying, don't forget to reply also to the list that way everyone can participate.

Regards,

Richard Broersma Jr.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Magnus Hagander 2006-10-27 20:36:36 Re: Problems running PostGreSQL silent install
Previous Message Greg Quinn 2006-10-27 20:27:57 Re: Problems running PostGreSQL silent install