Re: [GENERAL] How to have a autoincrement field?

From: Kevin Heflin <kheflin(at)shreve(dot)net>
To: Marc Eggenberger <me(at)ieo(dot)ch>
Cc: pgsql-general(at)postgreSQL(dot)org
Subject: Re: [GENERAL] How to have a autoincrement field?
Date: 1998-10-06 08:36:49
Message-ID: Pine.LNX.4.02.9810060334500.18355-100000@mercury.shreve.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, 6 Oct 1998, Marc Eggenberger wrote:

> With the current database I need a field that is automaticly
> incremented when data is added. I looked in the docs, and the
> mailinglist archive ... could find any suitable ...

I suppose there may be an easier/better way than this. But what I do when
I create the table I create a sequence, then have a field which
automatically increments the field ... Like so:

CREATE SEQUENCE game_id;

CREATE TABLE games (
game_id INT DEFAULT nextval('game_id') PRIMARY KEY,
game_title varchar (250),
etc....
)

Hope that helps.

Kevin

--------------------------------------------------------------------
Kevin Heflin | ShreveNet, Inc. | Ph:318.222.2638 x103
VP/Mac Tech | 333 Texas St #619 | FAX:318.221.6612
kheflin(at)shreve(dot)net | Shreveport, LA 71101 | http://www.shreve.net
--------------------------------------------------------------------

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kim ChongHo 1998-10-06 09:26:22 unsubscriber
Previous Message Tom Ivar Helbekkmo 1998-10-06 08:25:28 Re: [GENERAL] status on IPv6 implementation...