CSN <[EMAIL PROTECTED]> writes:
> I have three columns, and one of them can be null. I'd
> like to create a unique constraint across all three
> columns and allow only one null value. e.g.

UNIQUE won't do that for you, but you could brute force it with a
unique constraint plus a check constraint along the lines of
        (a notnull AND b notnull) OR
        (a notnull AND c notnull) OR
        (b notnull AND c notnull)

However, the real question is whether you think that "unique"
means "no more than one instance of x,y,NULL".  If that's what
you mean then UNIQUE isn't going to enforce it ...

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [EMAIL PROTECTED] so that your
       message can get through to the mailing list cleanly

Reply via email to