Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tsysy-0003Z9-LB for pgsql-sql@arkaria.postgresql.org; Wed, 09 Jan 2013 16:52:16 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1Tsysx-0001vT-Og for pgsql-sql@arkaria.postgresql.org; Wed, 09 Jan 2013 16:52:15 +0000 Received: from magus.postgresql.org ([87.238.57.229]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tsysw-0001ux-Mu for pgsql-sql@postgresql.org; Wed, 09 Jan 2013 16:52:14 +0000 Received: from mail-da0-f47.google.com ([209.85.210.47]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Tsyst-0006OD-0N for pgsql-sql@postgresql.org; Wed, 09 Jan 2013 16:52:13 +0000 Received: by mail-da0-f47.google.com with SMTP id s35so833829dak.20 for ; Wed, 09 Jan 2013 08:52:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=Tr6dwRek8U09cheEsIAkGX60qQ/YE3Nj0X9QfyI1GFc=; b=nxlKEjLNyB7TGjscEApvkyEG+Tu23WrK7kM3xMQCFnUQHuFL7QDYOx7IKc/0xkjXPD YYyKFJ0TiL7ZNoLW8higWNgtcNdlopq3BYpCBIripQkhBDIpDuUYjB5B7mfCJ223nOWQ 9rLjAdSP0MCJ9Vqh8x7w8tQ8u0BG27rcDFuRl4/w0jVziQQvRUv94dr7OwnyhLaz9ob1 67rq4AwBPPoz7gbOL1J3mWH49QoPJeJH/CoFZrDbPZebA7odvZ+Tdfj+D5+Psrmb4l8D oS1Kz8d28iY68AqIPtdM68aLReJ08e2PDWA6ugkl2kTPZ9ZHeBfIHHnvrvAwxq8uzx7p 3elA== X-Received: by 10.66.74.40 with SMTP id q8mr191280085pav.29.1357750328702; Wed, 09 Jan 2013 08:52:08 -0800 (PST) Received: from [192.168.200.187] ([199.48.193.159]) by mx.google.com with ESMTPS id is6sm41903380pbc.55.2013.01.09.08.52.05 (version=SSLv3 cipher=OTHER); Wed, 09 Jan 2013 08:52:07 -0800 (PST) Message-ID: <50EDA034.80200@gmail.com> Date: Wed, 09 Jan 2013 08:52:04 -0800 From: Adrian Klaver User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 MIME-Version: 1.0 To: emilu@encs.concordia.ca CC: PostgreSQL SQL List Subject: Re: How to generate drop cascade with pg_dump References: <50EC9574.9060500@encs.concordia.ca> In-Reply-To: <50EC9574.9060500@encs.concordia.ca> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org On 01/08/2013 01:53 PM, Emi Lu wrote: > Hello, > > May I know how to generate drop table cascade when pg_dump a schema please? > > E.g., > pg_dump -h db_server -E UTF8 -n schema_name -U schema_owner --clean > -d db_name >! ~/a.dmp > > In a.dmp, I'd like to get: > > drop table t1 cascade; > drop table t2 cascade; > ... ... > > Only dropping constraints within a schema is not good enough since there > are dependencies on other schema. That is a limitation of dumping by schema. http://www.postgresql.org/docs/9.2/interactive/app-pgdump.html "Note: When -n is specified, pg_dump makes no attempt to dump any other database objects that the selected schema(s) might depend upon. Therefore, there is no guarantee that the results of a specific-schema dump can be successfully restored by themselves into a clean database. If you want to reach across schemas you either need to do a whole database dump or modify a partial dump or create your own script. > > Thanks a lot! > Emi > > -- Adrian Klaver adrian.klaver@gmail.com -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql