pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Dmitry Ruban <dmitry@ruban.biz>
Cc: pgsql-sql@postgresql.org
Subject: Re: unique index on fields with possible null values
Date: Thu, 26 Jul 2007 22:49:31 -0400
Message-ID: <6521.1185504571@sss.pgh.pa.us> (raw)
In-Reply-To: <248746715.20070727125938@ruban.biz>
References: <248746715.20070727125938@ruban.biz>

Dmitry Ruban <dmitry@ruban.biz> writes:
> I'm trying to find a solution for unique index on fields with possible
> null values.

You appear to be hoping that a unique index would constrain a column to
contain at most one null entry.  It doesn't work like that, and I
strongly urge you to reconsider what you're using null for.  I think you
are in for a world of hurt, well beyond this one particular point,
because the SQL spec's semantics for null are not designed around the
idea that it represents a single distinguishable value.  What it
represents is "unknown".

			regards, tom lane



view thread (2+ messages)

Message-ID: <6521.1185504571@sss.pgh.pa.us>
Permalink:  ../6521.1185504571@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/6521.1185504571@sss.pgh.pa.us

 · 

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: tgl@sss.pgh.pa.us, dmitry@ruban.biz
  Subject: Re: unique index on fields with possible null values
  In-Reply-To: <6521.1185504571@sss.pgh.pa.us>

* 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