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 1in3DF-0000RR-EG for pgsql-general@arkaria.postgresql.org; Thu, 02 Jan 2020 16:20:41 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1in3DC-0005pg-Rc for pgsql-general@arkaria.postgresql.org; Thu, 02 Jan 2020 16:20:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1in3DC-0005pZ-Ho for pgsql-general@lists.postgresql.org; Thu, 02 Jan 2020 16:20:38 +0000 Received: from [66.111.4.28] (helo=out4-smtp.messagingengine.com) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1in3D7-0001nI-9H for pgsql-general@postgresql.org; Thu, 02 Jan 2020 16:20:38 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 7906C220FF; Thu, 2 Jan 2020 11:20:21 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Thu, 02 Jan 2020 11:20:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= subject:to:cc:references:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=fm1; bh=J KR8S0I0GecQ/kpp6PNS5J8qfET37AiI877y3jzLxBY=; b=kaWseLERyTnGSfMW1 zt5cEitp2CVW7A3Okkwb5B/jQhsCdgMtZvsb3t5opAv/BacskL2+jfCDfr3PPIS4 bdmSFDU7HR+tOco8V3N7pqYHC+tLVzb059iNZioqpYytKW0EJ7JetgtAtEVQtak5 ZgfZmcQ0En4my0NpI/G9xgEgCjfLhv+kGLxoqbDMzBdrtCx+cDo42q9A2AmAq2HD hrk0R1dyuldS4bsISK1dT3cKzWpaw8fPxmKMeINxxDNsrbgYEY0ZZcoNIdCTa+vO 19Lci9hhUr/qdNXLcYNQBc9Is/pqasTlc6Muw78Ar17oCtqFHPR6xawhri0++iOD gTfsg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=JKR8S0I0GecQ/kpp6PNS5J8qfET37AiI877y3jzLx BY=; b=pDaCgchxrlojwwuZd8FMrGSe2sV8ISRSUvFlGFhN/qUAirsAV/J8xvYtK N6XOv2As4anN+wRb6VLufggwhIPlM4ppqFdozJjzrwkdVEatG9GdJ69uBb1I/gxg UoziA6/d8Wy/NReOEQ+Y3GaK09Ast0eAlM6602wzt+8Nef0phda/l/noq5BLsEQX VV+4j58n8DSf7lJzGEnuLKcMwuJta3iJxoAjN2cQ3R9isOuzbrIrjSfFFbAPCKR2 hdoFwMXszv+6onzTBncU0AMOKXDXgfb5LTQliKEOCh8tUhIkr+BZh+GA7mc5kdLg gE4DjKTnMK7vvjYjvVm6dO6Jc/GZA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvdeguddgkeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepuffvfhfhkffffgggjggtgfesthejredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgnecukfhppeejuddrvddu vddruddvledrudelfeenucfrrghrrghmpehmrghilhhfrhhomheprggurhhirghnrdhklh grvhgvrhesrghklhgrvhgvrhdrtghomhenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Received: from [192.168.1.10] (unknown [71.212.129.193]) by mail.messagingengine.com (Postfix) with ESMTPA id 63841306080E; Thu, 2 Jan 2020 11:20:20 -0500 (EST) Subject: Re: Schema dump To: Tom Lane , Sonam Sharma Cc: pgsql-general References: <11647.1577972854@sss.pgh.pa.us> From: Adrian Klaver Message-ID: Date: Thu, 2 Jan 2020 08:20:19 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.3.1 MIME-Version: 1.0 In-Reply-To: <11647.1577972854@sss.pgh.pa.us> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.28 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 1/2/20 5:47 AM, Tom Lane wrote: > 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.) Caffeine kicked in, now I remember how the above happens: pg_restore -n utility -f pgrestore_utility.sql /production_12.out In pgrestore_utility.sql there is no CREATE SCHEMA. This came up in a previous thread: https://www.postgresql.org/message-id/6234.1569941612%40sss.pgh.pa.us > > regards, tom lane > > -- Adrian Klaver adrian.klaver@aklaver.com