Re: Neither column can be NULL if the column is part of the combination of primary key columns? - Mailing list pgsql-general

From Jaime Casanova
Subject Re: Neither column can be NULL if the column is part of the combination of primary key columns?
Date
Msg-id c2d9e70e05091611156a62504a@mail.gmail.com
Whole thread Raw
In response to Neither column can be NULL if the column is part of the combination of primary key columns?  (Emi Lu <emilu@cs.concordia.ca>)
List 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 ;)

pgsql-general by date:

Previous
From: Russ Brown
Date:
Subject: Re: Replication
Next
From: Bill Moseley
Date:
Subject: Setting WHERE on a VIEW with aggregate function.