Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1in0pH-0002IZ-Bk for pgsql-general@arkaria.postgresql.org; Thu, 02 Jan 2020 13:47:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1in0pG-00046Z-3F for pgsql-general@arkaria.postgresql.org; Thu, 02 Jan 2020 13:47:46 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1in0pF-00046Q-3X for pgsql-general@lists.postgresql.org; Thu, 02 Jan 2020 13:47:45 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1in0p8-0002GJ-Gb for pgsql-general@postgresql.org; Thu, 02 Jan 2020 13:47:43 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id 002DlYSa011648; Thu, 2 Jan 2020 08:47:34 -0500 From: Tom Lane To: Sonam Sharma cc: pgsql-general Subject: Re: Schema dump In-reply-to: References: Comments: In-reply-to Sonam Sharma message dated "Thu, 02 Jan 2020 12:45:10 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <11646.1577972854.1@sss.pgh.pa.us> Date: Thu, 02 Jan 2020 08:47:34 -0500 Message-ID: <11647.1577972854@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Sonam Sharma writes: > I took a schema dump using : pg_dump -n schema dbname . > When I restored this , it doesn't contain the constraints and indexes. Can > someone please help how to take a dump including all Hmph ... works for me. Where by "works", I mean "the dump contains constraints and indexes belonging to tables in the specified schema, and not any others". Maybe you could provide a little more detail? (One thing I notice is that the dump doesn't contain a "CREATE SCHEMA schema" command, so you have to do that manually before you restore. I guess this fits with the definition of the switch as selecting objects *in* the named schema, but it's still a possible gotcha.) regards, tom lane