Re: Unique Index - Mailing list pgsql-general

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

> That's ambiguous. Does it mean no two rows have all non-null columns that are
> all identical? Or does it mean no two rows have columns that excluding any
> null columns are identical.

OK, try the more formal definition in 8.9 <unique predicate>

         2) If there are no two rows in T such that the value of each column
            in one row is non-null and is equal to the value of the cor-
            responding column in the other row according to Subclause 8.2,
            "<comparison predicate>", then the result of the <unique predi-
            cate> is true; otherwise, the result of the <unique predicate>
            is false.

(11.7 defines the UNIQUE constraint in terms of the unique predicate)

            regards, tom lane

pgsql-general by date:

Previous
From: Greg Stark
Date:
Subject: Re: Unique Index
Next
From: "Frank D. Engel, Jr."
Date:
Subject: Re: [ADMIN] Oracle and Postgresql Play Nice Together on Same Computer?