Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ovL4B-00082F-I8 for pgsql-admin@arkaria.postgresql.org; Wed, 16 Nov 2022 16:15:11 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ovL49-0007a8-Ls for pgsql-admin@arkaria.postgresql.org; Wed, 16 Nov 2022 16:15:09 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ovL49-0007Zz-BK for pgsql-admin@lists.postgresql.org; Wed, 16 Nov 2022 16:15:09 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ovL47-0006TD-AJ for pgsql-admin@lists.postgresql.org; Wed, 16 Nov 2022 16:15:08 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 2AGGF5tT1349431; Wed, 16 Nov 2022 11:15:05 -0500 From: Tom Lane To: "David G. Johnston" cc: Erik Serrano , Pgsql-admin Subject: Re: backup to partitioned table In-reply-to: References: Comments: In-reply-to "David G. Johnston" message dated "Wed, 16 Nov 2022 09:04:16 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1349429.1668615305.1@sss.pgh.pa.us> Date: Wed, 16 Nov 2022 11:15:05 -0500 Message-ID: <1349430.1668615305@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > On Wed, Nov 16, 2022 at 8:56 AM Erik Serrano wrote: >> I have a partitioned table in postgresql version 9,5 to which I select and >> it returns data perfectly, but when I want to make a backup of the table, >> it only saves the structure without records. You realize of course that 9.5 is two years past EOL. >> When consulting the administrator, he informs me that it is a partitioned >> table and that it is always zero, but the data is in its "daughter" tables >> and that the select that it returns is the information that is housed in >> all its daughter tables. >> Now, given this, I wanted to know if there is any way to make a backup of >> the table that throws all the data from its child tables into a flat file. > I presume you are doing something with pg_dump...don't. Yeah, pg_dump is chartered to reproduce the original situation, so it won't help here. Also, 9.5 didn't have what we would now call partitioned tables. Presumably this is actually an inheritance tree, which complicates matters because there's no guarantee that the child tables even have the same column set as the parent. > Use a "COPY" command (or psql \copy) to produce the CSV file instead. You'll need to use "COPY (SELECT * FROM parent_table) TO wherever"; just plain "COPY parent_table" won't do it. regards, tom lane