Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1so3LS-007wUe-Il for pgsql-general@arkaria.postgresql.org; Tue, 10 Sep 2024 16:03:59 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1so3LR-00Favk-NS for pgsql-general@arkaria.postgresql.org; Tue, 10 Sep 2024 16:03:57 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1so3LR-00FavP-7R for pgsql-general@lists.postgresql.org; Tue, 10 Sep 2024 16:03:57 +0000 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1so3LM-000Up7-Vy for pgsql-general@postgresql.org; Tue, 10 Sep 2024 16:03:56 +0000 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-5becd359800so5334753a12.0 for ; Tue, 10 Sep 2024 09:03:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=peoplecall-com.20230601.gappssmtp.com; s=20230601; t=1725984233; x=1726589033; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=aFtIQApFbGMKmMe88gq9173DkS3dHxUK4OLAhKS/7kQ=; b=y07aD1ZhOAewIAP3x89vnXQbA1pMZ5OMs1D7+yzEvJ4QZp4gnwhKQ6PW30jtd/ZACw 7pswEyIN63p4+Y50FpgpHkG7Ty8hesssRlTc3xa2E0M0PM0AO/VCloiyWH/WjUmZgNAO C5fE+OYgmpcUKAE31mag/vCkIUiN6OBD2QClS6J06byrwbAq1/DRgJcYQh79xKfwW/Ce 1yw3NSVys/B92NHWGLGaOzx9+Y4bD9o6fdm9oR0YNhOTy13EhDhhEbrbiGImEsxsbFSC lfW8914ESYHqRAGeAvYW9kh0HErfHbtAlAip4bJgp+6Zgvs5vtx14GdKzsjzfIm7NRBh spjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725984233; x=1726589033; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aFtIQApFbGMKmMe88gq9173DkS3dHxUK4OLAhKS/7kQ=; b=RNI4q8pTRxT0jlGMa5Zy6kg/vQ6zS2ImbJISMthsIObMP8651lbvWz6S4yRwwu2PP/ TRNCzJuV5mq11bODUDvDhHzyovCoa/dtf6Q/pz5Xc5qCuRUnwzHqR2NVu6JLhO48hBBW ZpafJzvtVVT8Yt26Vo/AxyPKg6M6nt3cV+Fv8/AC70XrHNOafWX/Z77xTEc+yxKS/ydP mtZhq49anKp3RKwEZHrMEhG4G5fxgezM4uuFisHPdKyY/c0/EuVvTNcYpJvnu2iT4ZSe L8ecgAj+gcWlyLzPLw7lvCrdQMFK6H3ETyZ0Ty92Qp7hCquclkCfzsZ/86BlbwVxOK7K JrSQ== X-Gm-Message-State: AOJu0YzmxzUAIwXg8TpRfswmzymOzwWfPIoy5epQly+zhL13fjiA1+lV 4xwZBCwOvWE2x0dE5W124dd3bWpkG1RqeBOxhQF4yc6gE5SBBavD0ZZLNf3eVuYQo8UP8AkxEYe jwKSCZFtJPIqYhU0txiWRukfolzpGLqYffCzC1Z9ZckGnFg8= X-Google-Smtp-Source: AGHT+IGZJQzc/Q+PSDiuQlDoc4NJUgquvr+CdnFOex2B/WVW0fkLUtZ0p+6hTWXQfazSMp4iv8nEYVjKebqGSzQj3bg= X-Received: by 2002:a05:6402:518c:b0:5c2:1298:35ee with SMTP id 4fb4d7f45d1cf-5c3dc780bc5mr7602201a12.2.1725984232683; Tue, 10 Sep 2024 09:03:52 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Francisco Olarte Date: Tue, 10 Sep 2024 18:03:16 +0200 Message-ID: Subject: Re: Removing duplicate rows in table To: Rich Shepard Cc: pgsql-general@postgresql.org Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Rich: On Tue, 10 Sept 2024 at 17:32, Rich Shepard wrote: > Only a duplicate problem because when I created this table I didn't make the > proj_nbr column a PK. Always report this is if you have future problems, so people know if it is a case of pilot error or corruption, solutions differ and the good for ones may harm others. > > Also, if you do not have any uniqueness criteria consider adding an > > "id identity" column, it is useful when shit hits the fan. > Yep. that's what I will do. Bear in mind the relational model on which relational databases are modeled needs unique rows ( i.e., no two full rows should be equal on all fields ). It is not enforced in SQL, but now having it normally leads to problems. When it cannot be done in any other way, normally adding an identity column is a cheap way to make them unique. I had that problem with CDR tables ( it means call detail record, and until I managed to add circuit identification I had the problem that you can have two calls from and two the same two numbers with equal start and end times ) and solved it using an identity column ( added just for this purpose, after doing it a couple times using ctid in testing, it is slightly more expensive, but a lot more civilized ). Francisco Olarte.