pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Wells Oliver <wells.oliver@gmail.com>
Cc: pgsql-admin <pgsql-admin@postgresql.org>
Subject: Re: pg_dump -n schema -Fc has a DROP DATABASE command... confused
Date: Fri, 21 Jan 2022 00:02:58 -0500
Message-ID: <1123450.1642741378@sss.pgh.pa.us> (raw)
In-Reply-To: <CAOC+FBWrBPQOeL5_BXL2Xypr9aoJ56fbLsusyM7GU=5nXXaB_Q@mail.gmail.com>
References: <CAOC+FBWrBPQOeL5_BXL2Xypr9aoJ56fbLsusyM7GU=5nXXaB_Q@mail.gmail.com>

Wells Oliver <wells.oliver@gmail.com> writes:
> I did a few pg_dumps of different schemas using:
> pg_dump -h host dbname -n schema -Fc > schema.dump
> Opening it in VIM brings up a binary file (compressed, sure) but it looks
> like this:
> Which contains the line "DROP DATABASE". Which is weird-- it does not drop
> the database, I mean, I restored from the same file. Why is this in there?

pg_dump -Fc produces an archive file that pg_restore can use to
do whatever you can ask pg_restore to do.  One of those things
is the --clean switch, which says to drop every database object
before restoring.  So among the strings in the archive file you
will find DROP commands for all the dumped objects.  Those are
not issued by default, though.

(The other DROP commands might be obscured by compression.
Try --compress=0 to get a clearer view of what's in there.)

			regards, tom lane





view thread (3+ messages)

Message-ID: <1123450.1642741378@sss.pgh.pa.us>
Permalink:  ../1123450.1642741378@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1123450.1642741378@sss.pgh.pa.us

 · 

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-admin@postgresql.org
  Cc: tgl@sss.pgh.pa.us, wells.oliver@gmail.com
  Subject: Re: pg_dump -n schema -Fc has a DROP DATABASE command... confused
  In-Reply-To: <1123450.1642741378@sss.pgh.pa.us>

* 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