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 1sHpaf-00B54w-S3 for pgsql-general@arkaria.postgresql.org; Thu, 13 Jun 2024 18:54:30 +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 1sHpad-005lXk-KW for pgsql-general@arkaria.postgresql.org; Thu, 13 Jun 2024 18:54:28 +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 1sHpac-005lVD-8M for pgsql-general@lists.postgresql.org; Thu, 13 Jun 2024 18:54:28 +0000 Received: from wfhigh8-smtp.messagingengine.com ([64.147.123.159]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sHpaY-001ViL-Pe for pgsql-general@lists.postgresql.org; Thu, 13 Jun 2024 18:54:26 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfhigh.west.internal (Postfix) with ESMTP id 100731800095; Thu, 13 Jun 2024 14:54:19 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute5.internal (MEProxy); Thu, 13 Jun 2024 14:54:20 -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=1718304859; x=1718391259; bh=tZSsBegbieRo2GuI4jkkQbS3smn9nWiHa4JbpqPgGgY=; b= lc3CksT8S+5vOnSACIQAGP982yAEkVmOZ5VJDmcI+pvD1jECI+M69prbNJzyrQ9m 5POSge39H3CMxQU4bj0Rqxjs4FEmS4yoG7QyI212ouemoZpjVGNmXIF9WVXIFacA FEWFWJiqypishiVoE0pJYg9Feczft72XU2yNqqIWu32s/RSy7zK2pg+fC3JJlG5N YXK03PWeQMFnnXJuLga4ijBrGWEZBsPi361zTFsUTwmc4q5q9Gb3fRzkj1+KWDQG 6laNGitM08Xt2QLhyRoynDLDFdLXTFvTJBVAWPuyzITOvRJsKBF8ep1INhMGbCb+ gNndPFHnihqRh1Fv/OTCtw== 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=1718304859; x= 1718391259; bh=tZSsBegbieRo2GuI4jkkQbS3smn9nWiHa4JbpqPgGgY=; b=b iA1pTOz7IzODtlMQF+vmIYPTX7oHzhESSf0Ts7N4Gw2Qbyc/gNtbANeW6rVGxDK6 ysXYmFvO8JQVyY17jrAwkGlLsp30i2ktyZzWo/rd5anEhcHHzwE+PNgoTEK36Z9M iGFK/ltbzWx68qwv6zYEZJlcex9r/aiZokJLbWIyQV/IZNch1BMKX4mxnyszKYZo tuDcsX5dwFwWJKMRrHrujmyQOZ3ExbKMK2lp13Hddc3NNw/hCy7Lgd7uIKDLEx9M R0vBg2UHvcq1wz8W/PVh6Jqi0pq+1gdI6HdNHwjAAZMXyj5/cVrtIR325E9vsr7Y mfE9zdHS8Lfn+MUXAxLgQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfedujedguddvkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefkffggfgfuvfhfhfgjtgfgsehtkeertddtvdejnecuhfhrohhmpeetughr ihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtg homheqnecuggftrfgrthhtvghrnhepffelgeeifefgveduhedthfekuedtffejveegffeg jeevtdehgfduieetfeehjeehnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpe hmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 13 Jun 2024 14:54:19 -0400 (EDT) Message-ID: <0f40b8e8-a4a1-4c9b-9c90-7402e9edb628@aklaver.com> Date: Thu, 13 Jun 2024 11:54:18 -0700 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Reset sequence to current maximum value of rows To: Rich Shepard , "pgsql-generallists.postgresql.org" References: <387fa6c2-5de-f24-d522-46282597703@appl-ecosys.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 11:38, Rich Shepard wrote: > On Thu, 13 Jun 2024, Ron Johnson wrote: > > Today I saw that I had missed one new company and entered it using DEFAULT > for the company_nbr PK. When I looked at that table every company_name that > I had added yesterday was changed to the one inserted today. You sure you did not actually do an UPDATE without a WHERE? > >> What does your table definition look like? > >                                          Table "public.companies" >     Column    |         Type          | Collation | Nullable > |                  Default > > --------------+-----------------------+-----------+----------+-------------------------------------- >  company_nbr  | integer               |           | not null | > nextval('companies_org_nbr_seq'::regclass) >  company_name | character varying(64) |           | not null | > '??'::character varying >  url          | character varying(64) |           |          | >  email        | character varying(64) |           |          | >  industry     | character varying(24) |           | not null | > 'Other'::character varying >  status       | character varying(20) |           | not null | > 'Opportunity'::character varying >  comment      | text                  |           |          | >  ea_nbr       | integer               |           |          | 0 >  ea_amt       | numeric(10,2)         |           |          | 0.00 > Indexes: >     "organizations_pkey" PRIMARY KEY, btree (company_nbr) > Foreign-key constraints: >     "organizations_industry_fkey" FOREIGN KEY (industry) REFERENCES > industrytypes(ind_name) ON UPDAT > E CASCADE ON DELETE RESTRICT >     "organizations_status_fkey" FOREIGN KEY (status) REFERENCES > statustypes(stat_name) ON UPDATE CAS > CADE ON DELETE RESTRICT > Referenced by: >     TABLE "locations" CONSTRAINT "locations_org_nbr_fkey" FOREIGN KEY > (company_nbr) REFERENCES companies(company_nbr) ON UPDATE CASCADE ON DELETE > RESTRICT >     TABLE "people" CONSTRAINT "people_org_nbr_fkey" FOREIGN KEY > (company_nbr) REFERENCES companies(c ompany_nbr) ON UPDATE CASCADE ON > DELETE > RESTRICT > > Rich > > -- Adrian Klaver adrian.klaver@aklaver.com