Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfAgm-0006y5-PM for pgsql-general@arkaria.postgresql.org; Tue, 17 Nov 2020 23:47:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kfAgl-0001JE-H2 for pgsql-general@arkaria.postgresql.org; Tue, 17 Nov 2020 23:47:07 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfAgl-0001J7-8k for pgsql-general@lists.postgresql.org; Tue, 17 Nov 2020 23:47:07 +0000 Received: from mail.appl-ecosys.com ([50.126.108.78]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kfAge-0002bO-GU for pgsql-general@lists.postgresql.org; Tue, 17 Nov 2020 23:47:05 +0000 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id 874672627E2 for ; Tue, 17 Nov 2020 15:46:58 -0800 (PST) Date: Tue, 17 Nov 2020 15:46:58 -0800 (PST) From: Rich Shepard Reply-To: Rich Shepard To: pgsql-general@lists.postgresql.org Subject: PK issue: serial sequence needs updating Message-ID: User-Agent: Alpine 2.20 (LNX 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Running postgresql-12.2-x86_64-1_SBo on Slackware-14.2/x86_64. My restructed business database has populated tables, but the primary keys are not aware of the current maximum number since the table rows were added external to postgres and read in using psql. For example, I'm trying to add a new person to the people table which currently has 484 rows. The insert into statement provides all columns but the first, the PK (person_nbr) which is an int with an associated people_person_nbr_seq. Passing the insert statement to psql is rejected because there's already a person_nbr=1. How do I inform the sequence that nextval should be 485? Or, do I drop that sequence and restore it so it reads all existing table rows and their PKs? If I didn't clearly explain myself, ask and I'll try again. :-) TIA, Rich