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.96) (envelope-from ) id 1vw73m-003Swt-0T for pgsql-general@arkaria.postgresql.org; Fri, 27 Feb 2026 23:15:50 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vw73l-007g5w-03 for pgsql-general@arkaria.postgresql.org; Fri, 27 Feb 2026 23:15:49 +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.96) (envelope-from ) id 1vw73k-007g5f-2I for pgsql-general@lists.postgresql.org; Fri, 27 Feb 2026 23:15:48 +0000 Received: from fhigh-b8-smtp.messagingengine.com ([202.12.124.159]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1vw73h-00000001a0j-3pRq for pgsql-general@lists.postgresql.org; Fri, 27 Feb 2026 23:15:47 +0000 Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfhigh.stl.internal (Postfix) with ESMTP id B7E8E7A01E1; Fri, 27 Feb 2026 18:15:46 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Fri, 27 Feb 2026 18:15:46 -0500 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=fm2; t=1772234146; x=1772320546; bh=nrwu5VTPGzuTtHKlmb2MdgBuaDyM6/edstZvsXqeMOU=; b= JBNncCqo73ZeoJ8u4ShNvweMigU1f5sGKBpv2jl8/fUtcSAPgEYYZxAx20MpdDZS 6fHZc2HAVC4AmL7abbl5Bw7X8y0ho0GnrvcrnTieQ7MwViETE4SLnylZAAWLLhLN dsHC2RQ6wDwy32j5G/iu3TfE/uMspeVhextasbVxzL3ac8AobnZFGrxS1E8UJh0m h9gXIC1Q8aaG83wfNMXrdlY1X7DovvBUPhhXLXAJR2FmKNK5iUpjlPuSAPqUxXHS Tt47odqXfg1ptwzwRvfPJL+U/q7gOPngGQTFhNHz5LmH0DYHtYnJGYuzoSrFwyEV Zl96ttMVWloRghgFycQy3Q== 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-sender :x-me-sender:x-sasl-enc; s=fm3; t=1772234146; x=1772320546; bh=n rwu5VTPGzuTtHKlmb2MdgBuaDyM6/edstZvsXqeMOU=; b=A6qmlOaHMFFtrtiqi +4k/Pc723wqLa/S1OrSynio9qkv+eUznubMNnmtAG5I8vArFMrDBQAj/YixkrfWG X8NC97DIzsMbLWqUy4tHK/Vx7rDI4RKg1EJIYa+ocqCTRK/t2xGkJ6FFvrgciGze M7Cme7/ljwmUfCCivbvXj2zrqgfkOKsemb9oMfaJ77stcbyL7NXA2H22GKhOPu2g B8BD5Fv4ErhcpPBOPUOwFE27afENEZucJHJsG/W7eiSchGUdoDzEp9LgU6eH+q45 rS0WEwj0j5MrNPKl2RmWqX2eETywIxrcfjG13XtjBPyLnsNiHMHL3jrZEQ3tVroX rFhtw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvhedtvdelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfuhffvfhgjtgfgsehtkeertd dtvdejnecuhfhrohhmpeetughrihgrnhcumfhlrghvvghruceorggurhhirghnrdhklhgr vhgvrhesrghklhgrvhgvrhdrtghomheqnecuggftrfgrthhtvghrnhephfduveeufeevff ejieegheffteetheejveettdfgtdefvdegjefgvedvfefhteffnecuvehluhhsthgvrhfu ihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklhgrvhgvrh esrghklhgrvhgvrhdrtghomhdpnhgspghrtghpthhtohepvddpmhhouggvpehsmhhtphho uhhtpdhrtghpthhtohepughfghhpohhsthhgrhgvshefsehgmhgrihhlrdgtohhmpdhrtg hpthhtohepphhgshhqlhdqghgvnhgvrhgrlheslhhishhtshdrphhoshhtghhrvghsqhhl rdhorhhg X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Feb 2026 18:15:46 -0500 (EST) Message-ID: Date: Fri, 27 Feb 2026 15:15:45 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Can "on delete cascade" dependency be used in pgdump or similar ? From: Adrian Klaver To: dfgpostgres , pgsql-general@lists.postgresql.org References: <666bc91c-d5df-4a61-aa3a-30fb1e1c9fcb@aklaver.com> Content-Language: en-US In-Reply-To: <666bc91c-d5df-4a61-aa3a-30fb1e1c9fcb@aklaver.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 2/27/26 3:13 PM, Adrian Klaver wrote: > On 2/27/26 2:39 PM, dfgpostgres wrote: >> pg 15.15 on linux >> >> I have a DB with a table called "projects" which has a primary key >> column called "project".  Other child tables are linked in a primary/ >> foreign key relationship to "projects" with "on delete cascade".  Each >> of those may have grandchild tables linked in via other primary/ >> foreign key relationships, all with the "on delete cascade". >> Etc... .  If I delete project "a", it'll cascade delete the children, >> grandchild, etc...  recs.  All traces of project "a" will be gone. >> >> But I don't really want to lose the data from project "a", I want to >> archive it in another DB (same DB server, different DB).  The brain- >> numb method I've been using thus far is to copy the whole DB via >> pgdump then use that to create the DB "a_archive".  Then (here's the >> wasteful part) basically delete all the projects in "a-archive" EXCEPT >> for project "a".  Then, when that's done, go to the main DB and delete >> project "a". In effect, I just archived all the data for project "a" >> and put it in the DB called "a_archive".while relieving the main DB of >> the project "a" data. But what would be really neat is to leverage >> that cascade on delete stuff to just pgdump project "a" and use that >> to create "a_archive". >> >> Can pgdump do something like that ? > > The best you can do, with pg_dump, is use: Forget this idea. -- Adrian Klaver adrian.klaver@aklaver.com