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 1sHqZZ-00BAsT-A9 for pgsql-general@arkaria.postgresql.org; Thu, 13 Jun 2024 19:57:25 +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 1sHqZX-006ot4-4B for pgsql-general@arkaria.postgresql.org; Thu, 13 Jun 2024 19:57:24 +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 1sHqZW-006oqs-H9 for pgsql-general@lists.postgresql.org; Thu, 13 Jun 2024 19:57:23 +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 1sHqZU-001AeB-Tp for pgsql-general@lists.postgresql.org; Thu, 13 Jun 2024 19:57:22 +0000 Received: from salmo.appl-ecosys.com (salmo.appl-ecosys.com [192.168.55.1]) by mail.appl-ecosys.com (Postfix) with ESMTP id ED14B2A2B7C for ; Thu, 13 Jun 2024 12:57:19 -0700 (PDT) Date: Thu, 13 Jun 2024 12:57:19 -0700 (PDT) From: Rich Shepard To: pgsql-general@lists.postgresql.org Subject: Re: Reset sequence to current maximum value of rows In-Reply-To: Message-ID: <97d69b9-48de-3bd4-95d-df5614ff44a@appl-ecosys.com> References: <387fa6c2-5de-f24-d522-46282597703@appl-ecosys.com> <1b139d9a-b95f-f7c8-52fb-9d7442c69ad9@appl-ecosys.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 Thu, 13 Jun 2024, David G. Johnston wrote: > Because you specified company_name in the column listing for the things > you are inserting values for. So in column position 2 you must have a > value than can be inserted into the company_name column. It is utterly > immaterial how you specified the value for column position 1. > We can't help you understand if you don't show a complete working example > and ask a question in relation to that example. I suggest you start from > scratch, this time using scripts, so that your work is recorded and > replayable. David, INSERT into companies (company_nbr,company_name,industry,status) VALUES (DEFAULT,'A new company name', 'Manufacturing',DEFAULT); I always write scrips for SQL, R, GRASS, Python, bash. Above is a redacted version of the single name I tried adding to the companies table. Yesterday, before learning to use DEFAULT for the company_nbr PK I entered all rows using company_nbr 2342-2391. This morning, after running the single-line INSERT command company numbers from 2341-2392 all had 'A new company name' as the company_name. HTH, Rich