From: | "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com> |
---|---|
To: | Wells Oliver <wells(dot)oliver(at)gmail(dot)com> |
Cc: | pgsql-admin <pgsql-admin(at)postgresql(dot)org> |
Subject: | Re: pg_dump -n schema -Fc has a DROP DATABASE command... confused |
Date: | 2022-01-21 04:57:21 |
Message-ID: | CAKFQuwbbFPdYKdirZW8Dq+5GCrYdJySwFQm9KGXke3aKbT=CkA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
On Thu, Jan 20, 2022 at 9:45 PM Wells Oliver <wells(dot)oliver(at)gmail(dot)com> wrote:
> 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?
>
> Doing a text dump w/o -Fc yields a text file with no DROP statement.
>
The whole point of the custom format - which indeed defaults to compressed
mode (read the docs) - is to move any decisions about what to do during
restoring to the pg_restore commands. So, if the restore wants to drop the
database it has a drop database command available which it can execute. If
it doesn't that command will simply be skipped.
-Fp is a plain text format meant to be run via psql (or any other program
that can execute a basic SQL script - again, see the docs). Such a program
is not expected to specify restore conditions so whatever was defined
during the pg_dump will simply take effect.
David J.
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2022-01-21 05:02:58 | Re: pg_dump -n schema -Fc has a DROP DATABASE command... confused |
Previous Message | Wells Oliver | 2022-01-21 04:44:26 | pg_dump -n schema -Fc has a DROP DATABASE command... confused |