pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Teja Jakkidi <teja.jakkidi05@gmail.com>
To: Samed YILDIRIM <samed@reddoc.net>
Cc: pgsql-admin <pgsql-admin@lists.postgresql.org>
Subject: Re: Duplicate data even with primary keys enabled
Date: Fri, 28 Oct 2022 11:27:14 -0700
Message-ID: <59B1180A-4A4B-4A1A-B50A-C9D9B41AA67D@gmail.com> (raw)
In-Reply-To: <CAAo1mbnEV6QxHwnV6r2EUMXjb_Fz98+8eO6ZRU7eux4FTuF0YA@mail.gmail.com>
References: <CAAo1mbnEV6QxHwnV6r2EUMXjb_Fz98+8eO6ZRU7eux4FTuF0YA@mail.gmail.com>

Hi YILDIRIM,

Thanks for your response.

We have a composite primary key on 3columns. We are noticing multiple rows with same values in the 3pk columns which should not happen as primary constraint is defined on them.
Also, none of the columns are null.

Regards,
Teja. J.

> On Oct 28, 2022, at 10:59 AM, Samed YILDIRIM <samed@reddoc.net> 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.jakkidi05@gmail.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.
>> 

view thread (26+ messages)  latest in thread

Message-ID: <59B1180A-4A4B-4A1A-B50A-C9D9B41AA67D@gmail.com>
Permalink:  ../59B1180A-4A4B-4A1A-B50A-C9D9B41AA67D@gmail.com/
Also on:    postgresql.org/message-id/59B1180A-4A4B-4A1A-B50A-C9D9B41AA67D@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: teja.jakkidi05@gmail.com, samed@reddoc.net, pgsql-admin@lists.postgresql.org
  Subject: Re: Duplicate data even with primary keys enabled
  In-Reply-To: <59B1180A-4A4B-4A1A-B50A-C9D9B41AA67D@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox