Re: INSERT UNIQUE row?

From: Christophe Pettus <xof(at)thebuild(dot)com>
To: pf(at)pfortin(dot)com
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: INSERT UNIQUE row?
Date: 2023-07-09 23:02:14
Message-ID: 6669E40E-A427-4121-96FC-E4D90BFA6806@thebuild.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

A UNIQUE index can have any number of columns, so you can create an index with all of the appropriate columns listed. This is different from having a UNIQUE index on each individual column. In the former case, all of the columns together must be unique; in the latter case, as you mention, each index is evaluated separately.

> On Jul 9, 2023, at 15:58, pf(at)pfortin(dot)com wrote:
>
> Hi,
>
> Trying to figure out how to insert new property addresses into an
> existing table.
>
> Can a UNIQUE constraint be applied to an entire row? Adding UNIQUE to
> each column won't work in such a case since there are multiple properties
> * on the same street
> * in the same town
> * with the same number on different streets
> * etc...
>
> Each row is only unique as an entity; but the columns are not...
>
> Is this covered in the docs?
>
> Thanks,
> Pierre
>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message David G. Johnston 2023-07-09 23:42:15 Re: INSERT UNIQUE row?
Previous Message pf 2023-07-09 22:58:07 INSERT UNIQUE row?