Re: auto_increment - Mailing list pgsql-sql

From Bruno Wolff III
Subject Re: auto_increment
Date
Msg-id 20030922142243.GA23419@wolff.to
Whole thread Raw
In response to Re: auto_increment  (sad <sad@bankir.ru>)
List pgsql-sql
On Mon, Sep 22, 2003 at 09:15:04 +0400, sad <sad@bankir.ru> wrote:
> On Saturday 20 September 2003 10:23, you wrote:
> > On Sat, 2003-09-20 at 06:10, Muhyiddin A.M Hayat wrote:
> > > How to Create auto_increment field in PostreSQL.
> > > Can I create them using Trigger.
> >
> > Use the SERIAL datatype.  See also the functions nextval(), currval()
> > and setval().
> 
> I believe it is better to EXPLICITLY declare a SEQUENCE and 
> set the default value nextval() to the field.

The disadvantage of that system is that the dependency isn't detected.
With serial type you won't be able to drop the sequence without
dropping the column and when you drop the table, the sequence will
get dropped as well. (The preceding applies to 7.4. Things may not
be checked as well in 7.3.)


pgsql-sql by date:

Previous
From: Christoph Haller
Date:
Subject: Re: selecting duplicate records
Next
From: Wei Weng
Date:
Subject: GiST and full text search