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 1sHsVl-00BL3q-Ld for pgsql-general@arkaria.postgresql.org; Thu, 13 Jun 2024 22:01:37 +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 1sHsVi-008W6P-I5 for pgsql-general@arkaria.postgresql.org; Thu, 13 Jun 2024 22:01:35 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sHsVh-008W6G-2X for pgsql-general@lists.postgresql.org; Thu, 13 Jun 2024 22:01:35 +0000 Received: from wfhigh2-smtp.messagingengine.com ([64.147.123.153]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sHsVd-001X6K-EC for pgsql-general@lists.postgresql.org; Thu, 13 Jun 2024 22:01:33 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.west.internal (Postfix) with ESMTP id 47D4D180012B; Thu, 13 Jun 2024 18:01:25 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Thu, 13 Jun 2024 18:01:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1718316084; x=1718402484; bh=xFBpzIIoI/ntgnborQUj3j2tgfsFtrpaK7MlhPeIdng=; b= aPb2XUAZCXduQp2ftphTdfj719QqwcD5U3xrdj2WH5tWD2ryO81HqQfyeKodFPOj Vrehi9Na/kT2q7nRf4bMCeF8bB4wKGaytacHlKqp/9Rg9if82nMNQTBVU/vDFNwx QJWC9dSAxi4p6+rRhxU5xIsxvgjgFpE0BZGPEX4/40YwULuxSvc8n1bWq5kAueC5 NZGhMUZQTq1bTbKAabyEZlHArVC6Y8/acGauq83wzaXSO++YF+agcqsvoyNs/dt1 GlD1hVYnqDK9YXSqXE4A5duMGUNs7CGZiFm++LHppFHfi35+/raeOIvs1KSsB24F mpef1k2BGKLv3+leN/8N5Q== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1718316084; x= 1718402484; bh=xFBpzIIoI/ntgnborQUj3j2tgfsFtrpaK7MlhPeIdng=; b=k QqtDqH3J3R4bUcZLtg78wlVbQvUWETzJ5xF9YLK1CfSnC5VsYwR63/YukS5TZAYy QW6Mm+v+LPZpcjSW9l+CLb4QckwOnWdM9S7ZMw4BUcflx0nETMSz6HrKODURCezR LSm00JqQ99qd4DCQPHeSOohpKriwtnpqbylXJC3uZMSSkdqH8c4b+OZw0akSeDC8 liqz5938AGEGEAsOiKtxH8J2nTXy9B3EZkV0k05nPMihzUmfg9+LT/lH6JyUXZ+k O8IbjwmBbXXfbgHE+9m8UBjmugYvBw00IV/xAQEFZi3kZzVVnjy6O56rZ8cmYI+U GgebH5QW9DUO2yb6yDEzg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfedukedgtdefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvfhfhjggtgfesthekredttddvjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeffleegieefgfevudehtdfhkeeutdffjeevgeffgeej vedthefgudeiteefheejheenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmh grihhlfhhrohhmpegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtohhm X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 13 Jun 2024 18:01:23 -0400 (EDT) Message-ID: <4f319e27-0e54-40dd-888f-1e4c856a1b02@aklaver.com> Date: Thu, 13 Jun 2024 15:01:23 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Reset sequence to current maximum value of rows To: Rich Shepard , pgsql-general@lists.postgresql.org References: <387fa6c2-5de-f24-d522-46282597703@appl-ecosys.com> <1b139d9a-b95f-f7c8-52fb-9d7442c69ad9@appl-ecosys.com> <97d69b9-48de-3bd4-95d-df5614ff44a@appl-ecosys.com> Content-Language: en-US From: Adrian Klaver In-Reply-To: <97d69b9-48de-3bd4-95d-df5614ff44a@appl-ecosys.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 6/13/24 12:57, Rich Shepard wrote: > 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 Not with: Table "public.companies" [...] Indexes: "organizations_pkey" PRIMARY KEY, btree (company_nbr) That would throw duplicate key errors. Are you sure that you did not do this on the contacts table as the company FK back to companies? > single-line INSERT command company numbers from 2341-2392 all had 'A new > company name' as the company_name. > > HTH, > > Rich > > -- Adrian Klaver adrian.klaver@aklaver.com