From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Rich Shepard <rshepard(at)appl-ecosys(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: Reset sequence to current maximum value of rows |
Date: | 2024-06-13 22:24:51 |
Message-ID: | 53fd6cec-935e-415a-9267-07a3d43e498f@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 6/13/24 15:13, Rich Shepard wrote:
> On Thu, 13 Jun 2024, Adrian Klaver wrote:
>
>> Not with:
>>
>> Table "public.companies"
>>
>> [...]
>> Indexes:
>> "organizations_pkey" PRIMARY KEY, btree (company_nbr)
>>
>> That would throw duplicate key errors.
>>
>> Are you sure that you did not do this on the contacts table as the
>> company FK back to companies?
>
> Adrian,
>
> Yes, I'm sure. Early yesterday I did get duplicate key errors. That's
> when I
> looked on stackexchange to learn how to reset the sequence's max value to
> the value of the number of rows in the table. Not only did my attempt to
> add
> a single new company to the companies table change all company names in
> that
> one industry to the new name, but I just discovered that it changed all
> rows
> in that column to the new company name:
BEGIN;
<Run query>
<Check query results>
Then either
ROLLBACK;
COMMIT;
depending on the result of check.
>
> Regards,
>
> Rich
>
>
--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2024-06-13 22:29:01 | Re: Reset sequence to current maximum value of rows |
Previous Message | Rich Shepard | 2024-06-13 22:13:37 | Re: Reset sequence to current maximum value of rows |