Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sH0cR-0020De-FZ for pgsql-general@arkaria.postgresql.org; Tue, 11 Jun 2024 12:28:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sH0cP-0060cI-LB for pgsql-general@arkaria.postgresql.org; Tue, 11 Jun 2024 12:28:54 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sH0cP-0060c9-AU for pgsql-general@lists.postgresql.org; Tue, 11 Jun 2024 12:28:54 +0000 Received: from mail.appl-ecosys.com ([50.126.108.78]) by makus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sH0cJ-000n6E-El for pgsql-general@lists.postgresql.org; Tue, 11 Jun 2024 12:28:52 +0000 Received: from salmo.appl-ecosys.com (salmo.appl-ecosys.com [192.168.55.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id 8B8642A2B7C for ; Tue, 11 Jun 2024 05:28:45 -0700 (PDT) Date: Tue, 11 Jun 2024 05:28:45 -0700 (PDT) From: Rich Shepard To: pgsql-general@lists.postgresql.org Subject: Re: Gaps in PK sequence numbers [RESOLVED] In-Reply-To: <88E9C97A-E616-4162-9CAB-64C98C5620B6@thebuild.com> Message-ID: <92fc77dd-8b98-2810-107b-aac4795191d5@appl-ecosys.com> References: <35fd10ab-5f7f-7a57-9cc5-c03d81476d13@appl-ecosys.com> <88E9C97A-E616-4162-9CAB-64C98C5620B6@thebuild.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Mon, 10 Jun 2024, Christophe Pettus wrote: > The sequence functions are documented here: > https://www.postgresql.org/docs/current/functions-sequence.html > setval is the function you want. You can use a SELECT so you don't have to > copy values around: > select setval('t_pk_seq', (select max(pk) from t)); > That form of setval() sets the sequence so that the next value will be one > more than the value you set it to, so you don't have to do max()+1 there. Thanks again, Christophe. Regards, Rich