Re: Neither column can be NULL if the column is part of the combination of primary key columns?

From: Jaime Casanova <systemguards(at)gmail(dot)com>
To: emilu(at)cs(dot)concordia(dot)ca
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Neither column can be NULL if the column is part of the combination of primary key columns?
Date: 2005-09-16 18:15:41
Message-ID: c2d9e70e05091611156a62504a@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>
> To allow *col2* to be NULL and make record combination (col1, col2)
> unique, I should setup
> unique (col1, col2) ?
>
> Thanks,
> Emi
>

no, you must create a partial unique index...

create unique index indice_col2 on table(col1, col2) where col2 is not null;

--
Atentamente,
Jaime Casanova
(DBA: DataBase Aniquilator ;)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Bill Moseley 2005-09-16 18:30:27 Setting WHERE on a VIEW with aggregate function.
Previous Message Russ Brown 2005-09-16 17:51:35 Re: Replication