Re: auto_increment

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: sad <sad(at)bankir(dot)ru>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: auto_increment
Date: 2003-09-22 14:22:43
Message-ID: 20030922142243.GA23419@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, Sep 22, 2003 at 09:15:04 +0400,
sad <sad(at)bankir(dot)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.)

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Wei Weng 2003-09-22 15:02:09 GiST and full text search
Previous Message Christoph Haller 2003-09-22 13:25:14 Re: selecting duplicate records