Re: Why doesn't the SERIAL data type automatically have a

From: Ferindo Middleton Jr <fmiddleton(at)verizon(dot)net>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: "Jim C(dot) Nasby" <jnasby(at)pervasive(dot)com>, Scott Marlowe <smarlowe(at)g2switchworks(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Why doesn't the SERIAL data type automatically have a
Date: 2005-10-04 23:54:47
Message-ID: 43431647.1010807@verizon.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Richard Huxton wrote:
> Jim C. Nasby wrote:
>>>>> Is there some reason why the SERIAL data type doesn't
>>>>> automatically have a UNIQUE CONSTRAINT.
>>>>
>>>> It used to, and then we decoupled it.
> [snip]
>> Arguably it would have been better to make the default case add either
>> UNIQUE or PRIMARY KEY with a way to over-ride.
>
> Arguably SERIAL shouldn't be a type at all since it's nothing to do
> with defining a set of values. If you were being clean about it you'd
> have to have something like "mycol INTEGER SERIAL UNIQUE", then wire
> SERIAL to a generator function for the type in question.
>
>> If newbies are getting burned maybe it would be useful to toss a NOTICE
>> or maybe even WARNING when a serial is created without a unique
>> constraint of some kind?
>
> Don't forget the NOT NULL too. Perhaps simpler to have a PGIDENT
> pseudo-type that implies "UNIQUE NOT NULL" and then explain the
> difference in the docs.
>
> --
> Richard Huxton
> Archonet Ltd
>
I like Richard's idea. That seems to be the best way to go.

Ferindo
Sleekcollar

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jim C. Nasby 2005-10-05 00:06:54 Re: Why doesn't the SERIAL data type automatically have a
Previous Message Ferindo Middleton Jr 2005-10-04 23:50:28 Re: Why doesn't the SERIAL data type automatically have a