Re: Reset sequence to current maximum value of rows

From: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Reset sequence to current maximum value of rows
Date: 2024-06-13 18:24:37
Message-ID: 1b139d9a-b95f-f7c8-52fb-9d7442c69ad9@appl-ecosys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, 13 Jun 2024, David G. Johnston wrote:

> You need to show your work here. As your PK is a number it cannot have a
> company name as a value and so this doesn't make sense.

David,

insert into companies (company_nbr,company_name,industry,status) values
(DEFAULT,'new company name','Industry','Opportunity')

With DEFAULT as the company_nbr why can't the company_name not have a value?

> It didn't...

I changed the company_name for all company_nbr using the 'new company name'
for all rows with 'Industry' in that column.

> And how to I reset sequences to ignore all current values
> This doesn't make sense...

Then I cannot use the sequence for adding new rows in the table and I must
manually enter each PK number?

> If you use the default when inserting the next value in the sequence is
> used.

Yes, that's the theory. It didn't work for me and why it didn't is what I
want to understand.

Regards,

Rich

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rich Shepard 2024-06-13 18:38:43 Re: Reset sequence to current maximum value of rows
Previous Message David G. Johnston 2024-06-13 17:28:10 Re: Reset sequence to current maximum value of rows