Search Postgresql Archives

Re: Reset sequence to current maximum value of rows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.klaver@xxxxxxxxxxx






[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux