Re: Automatic PK values not added to new rows

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Ron <ronljohnsonjr(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Automatic PK values not added to new rows
Date: 2022-05-26 04:19:48
Message-ID: 78550fd9-b26e-3827-b95c-b68f88938916@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 5/25/22 20:10, Ron wrote:
> On 5/25/22 13:17, Rich Shepard wrote:
>> On Wed, 25 May 2022, David G. Johnston wrote:
>>
>>> The value the sequence provides next is wholly independent of everything
>>> except the state of the sequence. It doesn’t care how many rows any
>>> table,
>>> even its owner, has. The very existence of the delete command should
>>> make
>>> this self-evident.
>>
>> David J.,
>>
>> I didn't know that.
>
> people_person_nbr_seq would have to somehow peek into public.people and
> automatically update itself.  I'd be hopping mad if Postgresql did that
> after I explicitly set the value of people_person_nbr_seq to the value
> of my choosing, as if Postgresql knows better than I do what I want the
> next value of people_person_nbr_seq to be.

Though to be honest if you are setting up an automatic id system, be it
serial or identity, and then overriding it with your own values you are
looking for issues. Either let the system do it's thing and be an out of
site out of mind number generator or take full control of the id
generation yourself.

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ajin Cherian 2022-05-26 05:45:47 Re: Support logical replication of DDLs
Previous Message Ron 2022-05-26 03:10:39 Re: Automatic PK values not added to new rows