Re: Unique Index

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Unique Index
Date: 2005-01-20 13:14:08
Message-ID: 5416.1106226848@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Greg Stark <gsstark(at)mit(dot)edu> writes:
> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
>> Direct your complaints to the ISO SQL standards committee.

> The SQL standard generally treats NULLs as a escape hatch for constraints.

Not for UNIQUE constraints. SQL92 section 4.10 "Integrity constraints":

A unique constraint is satisfied if and only if no two rows in
a table have the same non-null values in the unique columns. In
addition, if the unique constraint was defined with PRIMARY KEY,
then it requires that none of the values in the specified column or
columns be the null value.

The short answer to this thread is that the OP is misusing nulls,
and should pick some non-null value to be his "placeholder".

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Jiří Němec 2005-01-20 13:29:29 Duplicate counting
Previous Message Troyston Campano 2005-01-20 13:03:42 Re: Oracle and Postgresql Play Nice Together on Same Computer?