Re: Constrain duplicate patterns

From: Russell Shaw <rjshaw(at)iprimus(dot)com(dot)au>
To:
Cc: "'pgsql-novice(at)postgresql(dot)org'" <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Constrain duplicate patterns
Date: 2004-02-01 09:46:46
Message-ID: 401CCB06.5090904@iprimus.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Michael Glaesemann wrote:
>
> On Feb 1, 2004, at 6:06 PM, Russell Shaw wrote:
>
>> Hi,
>>
>> Is there a way to make postgresql report an error if when
>> inserting data, a multiple-column combination is duplicated?
>
> I believe you're looking for UNIQUE(part_id, vendor_id), if you want to
> prevent this from happening. If you just want it to report an error, but
> allow the insert/update anyway, maybe a trigger? Not sure about that
> though.

Hi,
Thanks. I used this:

create table parts_vendors (
part_id integer references parts (part_id),
vendor_id integer references vendors (vendor_id),
unique(part_id,vendor_id)
)

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message joseph speigle 2004-02-01 10:40:55 quote style in buffer
Previous Message joseph speigle 2004-02-01 09:40:56 Re: Constrain duplicate patterns