Re: unique key and nulls

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Patrick Welche <prlw1(at)newn(dot)cam(dot)ac(dot)uk>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: unique key and nulls
Date: 2006-12-05 18:30:17
Message-ID: 9031.1165343417@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Patrick Welche <prlw1(at)newn(dot)cam(dot)ac(dot)uk> writes:
> patrimoine=# alter table socket add unique(port_id);
> NOTICE: ALTER TABLE / ADD UNIQUE will create implicit index "socket_port_id_key" for table "socket"
> ERROR: could not create unique index
> DETAIL: Table contains duplicated values.
> patrimoine=# select port_id,count(id) from socket group by port_id having count(id)>2;

count(id)>1 would be the appropriate check, no? Or really count(*)>1
... the above will give misleading answers if id can be null.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Volkan YAZICI 2006-12-05 18:41:43 Re: Preserving Cluster-Wise Data
Previous Message Tom Lane 2006-12-05 18:27:52 Re: Preserving Cluster-Wise Data