Re: Removing duplicate rows in table

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Removing duplicate rows in table
Date: 2024-09-10 15:45:21
Message-ID: 28d34da0-c58c-4237-b71d-5907517ace45@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 9/10/24 08:29, Rich Shepard wrote:
> On Tue, 10 Sep 2024, Adrian Klaver wrote:
>
>> Is there a Primary Key or Unique index on this table?
>
> Adrian,
>
> No. It didn't occur to me to make the project number a PK as this table is
> not related to others in the database.
>
> But, yesterday it occurred to me to make the proj_nbr a PK to eliminate
> future issues.
>

You might want to do something like:

select proj_nbr, count(*) as ct from projects group by proj_nbr;

to see how big a problem it is. If it is only a few projects it could
just a matter of manually deleting the extras.

Whatever you do:

1) Make sure you have a backup of at least that table.

2) Do the data changes as BEGIN; <changes> COMMIT; or ROLLBACK;

> Thanks,
>
> Rich
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Francisco Olarte 2024-09-10 16:03:16 Re: Removing duplicate rows in table
Previous Message Rich Shepard 2024-09-10 15:35:48 Re: Removing duplicate rows in table