Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ooV5K-0005rf-OT for pgsql-admin@arkaria.postgresql.org; Fri, 28 Oct 2022 19:32:06 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ooV5J-0003fG-Ks for pgsql-admin@arkaria.postgresql.org; Fri, 28 Oct 2022 19:32:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ooV5J-0003f6-9u for pgsql-admin@lists.postgresql.org; Fri, 28 Oct 2022 19:32:05 +0000 Received: from mail-oa1-x2b.google.com ([2001:4860:4864:20::2b]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ooV5D-000831-JP for pgsql-admin@lists.postgresql.org; Fri, 28 Oct 2022 19:32:04 +0000 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-1322d768ba7so7403444fac.5 for ; Fri, 28 Oct 2022 12:31:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:from:to:cc:subject:date:message-id :reply-to; bh=8cWX1yBv1DqkMDmgowq5Tg7EpgWUdmbPune6UnPGxww=; b=gyK2zyC9BFpgbKLhfWW990r+7fJYoTJyQxr06uhEZ7kQbCKxWFMpzwog4Icnx0M0MW dp6iMrwrzabtzoq4gs6B7oCLUra7FpFiOQSxwkMd/EK+IDslOtd4zLpXrM4m0dstNXOF Gosf+U5rAdI5FAJ3VEpr2/kOMAfw2aVp1/kWEdnph7UkhKnv/iE6MG+xD9zvudSAAyA2 90XIZvgjV8Rc7lqN19V+Aym3bJuPgN1ECue04vOrRF3HZPahSAY5yu5YlD8rJM+rrTaj sl1iBjpo1tjLxqoftz+u6cdcL12JAXPL9380BtlKi3acFg9aWllNQgWSo2EzvMvm2m8n Me8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:from:references:to:content-language:subject:user-agent :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=8cWX1yBv1DqkMDmgowq5Tg7EpgWUdmbPune6UnPGxww=; b=WYjCqXmWPHDZLp/FIpNoQZdYKgWijAEi300vFQNcA91kvyvlZ+vn16bHuholQVRhuW ukj3hsFWwnQTgYkDPYgqKPI9uGDmoei26PbsQoFYhcb+0JgDYy6xWDc5J/KQJR92xXTI 0UwXSO6gJKLy0SNFrRs4el5K61Cb50+sFyknR02dqLVG5HFIaLHBTyH2xBOvHS/WiOEX DM1YNuo9CoNim+h6RPsVIneUezDnGxDfgkzTG5B0NgDBruNGHGpTKnHeMccwvPFgkhpP MIOvpkYP0V4wP57IibQPQG6u5uySaYJs4kigyRb5bC7DzIBI+DwbLFJvy6TfK+YDUJcf +BcA== X-Gm-Message-State: ACrzQf0Cm3vyV6r1R2JUGfpZ+CpMGMPk6Qaz3PX9fNO6RrpOpMt2hex6 /Un1nTTTw6OtWqSDoCpF3KgvDIHf8Og= X-Google-Smtp-Source: AMsMyM66FyXPpFmHcaz4arM8yGiqJMJOWkBBt7EDKMMpblz6fmcIgr7P9VRr+3NbGWnBUEMp+UrD+w== X-Received: by 2002:a05:6870:5596:b0:13c:831a:f150 with SMTP id n22-20020a056870559600b0013c831af150mr443603oao.234.1666985518586; Fri, 28 Oct 2022 12:31:58 -0700 (PDT) Received: from [192.168.88.10] (ip68-11-68-85.no.no.cox.net. [68.11.68.85]) by smtp.googlemail.com with ESMTPSA id q6-20020a056870e88600b00130e66a7644sm2551231oan.25.2022.10.28.12.31.57 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 28 Oct 2022 12:31:57 -0700 (PDT) Content-Type: multipart/alternative; boundary="------------HtmkU03reiEs4h7g35C3qbd9" Message-ID: <374b5d93-8681-b260-393f-73581c5344dc@gmail.com> Date: Fri, 28 Oct 2022 14:31:57 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: Duplicate data even with primary keys enabled Content-Language: en-US To: pgsql-admin@lists.postgresql.org References: <8A481F39-97D5-4778-AC3C-A34CD29E00AB@gmail.com> From: Ron In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------HtmkU03reiEs4h7g35C3qbd9 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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, 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. --------------HtmkU03reiEs4h7g35C3qbd9 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit 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.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.


--
Angular momentum makes the world go 'round.
--------------HtmkU03reiEs4h7g35C3qbd9--