Re: Unique Index - Mailing list pgsql-general

From Tom Lane
Subject Re: Unique Index
Date
Msg-id 5416.1106226848@sss.pgh.pa.us
Whole thread Raw
In response to Re: Unique Index  (Greg Stark <gsstark@mit.edu>)
Responses Re: Unique Index
List pgsql-general
Greg Stark <gsstark@mit.edu> writes:
> Tom Lane <tgl@sss.pgh.pa.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

pgsql-general by date:

Previous
From: "Troyston Campano"
Date:
Subject: Re: [ADMIN] Oracle and Postgresql Play Nice Together on Same Computer?
Next
From: Jiří Němec
Date:
Subject: Duplicate counting