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 1sHssQ-00BOQH-77 for pgsql-general@arkaria.postgresql.org; Thu, 13 Jun 2024 22:25:02 +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 1sHssM-008qhs-9V for pgsql-general@arkaria.postgresql.org; Thu, 13 Jun 2024 22:24:59 +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 1sHssL-008qhk-UD for pgsql-general@lists.postgresql.org; Thu, 13 Jun 2024 22:24:58 +0000 Received: from wfhigh2-smtp.messagingengine.com ([64.147.123.153]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sHssK-001BZs-09 for pgsql-general@lists.postgresql.org; Thu, 13 Jun 2024 22:24:57 +0000 Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfhigh.west.internal (Postfix) with ESMTP id E1AC118000B4; Thu, 13 Jun 2024 18:24:52 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Thu, 13 Jun 2024 18:24:53 -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=1718317492; x=1718403892; bh=EgxLs4QwpX2wOnGyA491IDLsaYbyu+LYyxv4WNUmyII=; b= qZV0uPsFD5ralvemf22LWNZfAdwDdekXxTZhCvpAghiLCpKQSh0e+ei/k3Xw5NP4 Ienisd4Vbu5F3aD3WtmLR4K497whd0Skj7iz1ogx3KYD+TmAKRB4911FqOa1ZGcq a8PJKJpIJSKHaY4hwIlAfqSMEa2bMHfYsewUvg+x+uliY50pY+YXBc9LXdGRCtJH MsLjJcUAu3aHatA/UQvOxwcFdyPVcfK/K8LvQtZ2o4iFstPPzqK7epBq3sLKr5QO NAAoUdffInMyVK6ILQ1TF9RQ5jnxzU16uWrwfFODVFjKwlxZSkMgjHZCsAi6K5l5 WQlzWpslyWLNU8xGoBsgwA== 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=1718317492; x= 1718403892; bh=EgxLs4QwpX2wOnGyA491IDLsaYbyu+LYyxv4WNUmyII=; b=J 3CNQrEss70H9oT3t6LY6qFDhc9fXSWuSLOdiy1/38tGQfnH2gJiYSXaO0Rqj8qIx dOI/f2MS+YPpU9Y1BampGzl/fRToEMAEMtdKK0BDeDJaQroy8HLnyFqB+Djh3hkv rlQS7GKpMvrrcLKe0wDKX/Hi0GTFORsF88wE3iKCYI2Ws8a26ebBZbP4vr4vsUlm HkuMjn0uS/RiSZOXaHIDbUCvn/noquCrF+kwsaPGsioKUrw9Q0z3nfUmqzVZbhCX 7WbTpzX555yUXD019D6fEZQCn8Kb3X6LPbAHLe65ZEc6lKTGUfxSp5KlA8DN8Xpo 90kl55m3ZiHDAMUniYlyg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfedukedgtdelucetufdoteggodetrfdotf 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:24:51 -0400 (EDT) Message-ID: <53fd6cec-935e-415a-9267-07a3d43e498f@aklaver.com> Date: Thu, 13 Jun 2024 15:24:51 -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> <4f319e27-0e54-40dd-888f-1e4c856a1b02@aklaver.com> Content-Language: en-US From: Adrian Klaver In-Reply-To: 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 15:13, Rich Shepard wrote: > On Thu, 13 Jun 2024, Adrian Klaver wrote: > >> 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? > > Adrian, > > Yes, I'm sure. Early yesterday I did get duplicate key errors. That's > when I > looked on stackexchange to learn how to reset the sequence's max value to > the value of the number of rows in the table. Not only did my attempt to > add > a single new company to the companies table change all company names in > that > one industry to the new name, but I just discovered that it changed all > rows > in that column to the new company name: BEGIN; Then either ROLLBACK; COMMIT; depending on the result of check. > > Regards, > > Rich > > -- Adrian Klaver adrian.klaver@aklaver.com