public inbox for [email protected]  
help / color / mirror / Atom feed
From: Adrian Klaver <[email protected]>
To: Rich Shepard <[email protected]>
To: [email protected]
Subject: Re: Reset sequence to current maximum value of rows
Date: Thu, 13 Jun 2024 15:24:51 -0700
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
	<CAKFQuwba=vb16vR47W0oo3SirkJ+UqLEg5j9-fqe+vm=0Q7_qw@mail.gmail.com>
	<[email protected]>
	<CAKFQuwY4PXdUYWxWzZ+idD64GLA2vrKf_UDcSPf=5VuYSDNRUA@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<[email protected]>

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
[email protected]







view thread (10+ messages)  latest in thread

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: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: Reset sequence to current maximum value of rows
  In-Reply-To: <[email protected]>

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

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