Re: Composite Unique Key - Doubt

From: Vibhor Kumar <vibhor(dot)kumar(at)enterprisedb(dot)com>
To: Technical Doubts <online(dot)technicaldoubts(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Composite Unique Key - Doubt
Date: 2013-06-20 19:08:50
Message-ID: 3DC3AFB1-0668-4927-8C52-02C98D17D284@enterprisedb.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice


On Jun 20, 2013, at 1:56 AM, Technical Doubts <online(dot)technicaldoubts(at)gmail(dot)com> wrote:

> Am using Postgres 9.2
>
> I am having a table
>
> technologies
> (
> technologyid bigint,
> status character(1),
> implementeddate date
> *CONSTRAINT technologies_uq UNIQUE (technologyid, status, implementeddate)*
> )
>
> entering data as
>
> insert into technologies (technologyid,status,implementeddate)
> values
> (123,'P',null),
> (123,'P',null);
>
> 2 rows affected.
>
> table accepting duplicate values in spite of composite unique constraint..
> where I am doing wrong?

Reason is null is not equal to null.

So, 123,'P',null and 124,'P',null is actually unique composite key.

Thanks & Regards,
Vibhor Kumar
EnterpriseDB Corporation
The Postgres Database Company
Blog:http://vibhork.blogspot.com

In response to

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message carlosinfl . 2013-06-20 21:13:15 Postgres User Home ENV Help
Previous Message Technical Doubts 2013-06-20 05:56:51 Composite Unique Key - Doubt