Re: Duplicate data even with primary keys enabled

From: Samed YILDIRIM <samed(at)reddoc(dot)net>
To: Ron <ronljohnsonjr(at)gmail(dot)com>
Cc: pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: Duplicate data even with primary keys enabled
Date: 2022-10-29 14:53:04
Message-ID: CAAo1mbnRAA6oYkRFzzOYt_wpLHh+9oPwHbDjwnU7WgEd-oCw+Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Hi Ron,

No, I'm not :) I gave general information about unique indexes that would
help Teja with his issue. Primary keys and unique constraints are similar
to each other. :)

Best regards.
Samed YILDIRIM

On Fri, 28 Oct 2022, 22:32 Ron, <ronljohnsonjr(at)gmail(dot)com> wrote:

> You're confusing PRIMARY KEY with UNIQUE.
>
> On 10/28/22 12:59, Samed YILDIRIM wrote:
>
> Hello Teja,
>
> Could you please add some example lines? I need to see some examples to
> say something more accurate.
>
> First of all, null != null in PostgreSQL. So, if any of those three
> columns is null, it means it is unique and won't violate unique constraints
> even if there is another row with the same values.
>
> Another thing, if you defined a composite primary key on those 3 columns,
> it means that it will prevent inserting another row that has exactly the
> same values on those columns. If you want to keep values unique on each
> individual columns, you need to create 3 separate unique
> indexes/constraints.
>
> Best regards.
> Samed YILDIRIM
>
> On Fri, 28 Oct 2022, 19:52 Teja Jakkidi, <teja(dot)jakkidi05(at)gmail(dot)com> wrote:
>
>> Hello Admin team,
>>
>> I have an issue where we are seeing duplicate data in one of the tables.
>> The table has primary key constraint defined on 3columns and we are seeing
>> duplicate data in these column data.
>> Is there any way to figure out why this could happen? Also is there a way
>> that the primary key constraint can be disabled during inserts?? If so how
>> can we find who disabled it? (Note that audit is not enabled for the table)
>> Please suggest.
>>
>> Thanks,
>> Teja.
>>
>>
> --
> Angular momentum makes the world go 'round.
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Samed YILDIRIM 2022-10-29 15:06:14 Re: Duplicate data even with primary keys enabled
Previous Message Samed YILDIRIM 2022-10-29 14:47:20 Re: Duplicate data even with primary keys enabled