pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@gmail.com>
To: emilu@encs.concordia.ca
Cc: PostgreSQL SQL List <pgsql-sql@postgresql.org>
Subject: Re: How to generate drop cascade with pg_dump
Date: Wed, 09 Jan 2013 08:52:04 -0800
Message-ID: <50EDA034.80200@gmail.com> (raw)
In-Reply-To: <50EC9574.9060500@encs.concordia.ca>
References: <50EC9574.9060500@encs.concordia.ca>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-sql>

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



view thread (2+ messages)

Message-ID: <50EDA034.80200@gmail.com>
Permalink:  ../50EDA034.80200@gmail.com/
Also on:    postgresql.org/message-id/50EDA034.80200@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: adrian.klaver@gmail.com, emilu@encs.concordia.ca
  Subject: Re: How to generate drop cascade with pg_dump
  In-Reply-To: <50EDA034.80200@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox