pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Bruno Wolff III <bruno@wolff.to>
To: sad <sad@bankir.ru>
Cc: pgsql-sql@postgresql.org
Subject: Re: auto_increment
Date: Mon, 22 Sep 2003 09:22:43 -0500
Message-ID: <20030922142243.GA23419@wolff.to> (raw)
In-Reply-To: <200309220915.04899.sad@bankir.ru>
References: <008501c37f35$832e26e0$1f00a8c0@middinkcomp>
	<1064038995.5359.70.camel@linda.lfix.co.uk>
	<200309220915.04899.sad@bankir.ru>

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.)



view thread (27+ messages)

Message-ID: <20030922142243.GA23419@wolff.to>
Permalink:  ../20030922142243.GA23419@wolff.to/
Also on:    postgresql.org/message-id/20030922142243.GA23419@wolff.to

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: bruno@wolff.to, sad@bankir.ru
  Subject: Re: auto_increment
  In-Reply-To: <20030922142243.GA23419@wolff.to>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox