pg_dump'ed file contains "DROP DATABASE" - Mailing list pgsql-general

From pf@pfortin.com
Subject pg_dump'ed file contains "DROP DATABASE"
Date
Msg-id 20230220132705.3a81a48f.pfortin@pfortin.com
Whole thread Raw
Responses Re: pg_dump'ed file contains "DROP DATABASE"  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: pg_dump'ed file contains "DROP DATABASE"  (Adrian Klaver <adrian.klaver@aklaver.com>)
List pgsql-general
[Still a newbie; but learning fast...]

Hi,

A remote team member is helping out by dumping some of his tables via
pgAdmin4 on Windows.  My DB is on Linux.

The other day, I restored his first file with:
  pg_restore --host "localhost" --port "5432" --username "postgres"
  --no-password --dbname "myname" --create --clean --verbose "dumpfile"

when I saw this:

  pg_restore: dropping DATABASE myname
  Command was: DROP DATABASE myname;

  pg_restore: error: could not execute query: 
    ERROR:  cannot drop the currently open database

Digging into the pg_dump'ed files, I see:

CREATE DATABASE myname WITH TEMPLATE = template0 ENCODING = 'UTF8'
LOCALE_PROVIDER = libc LOCALE = 'English_United States.1252'; 
DROP DATABASE myname;
^^^^^^^^^^^^^^^^^^^^^

Was my 134 table[1] myname DB saved because it was open?  If the dump file
contains the above statements, how can I be absolutely certain I won't
lose the DB?  I'm obviously quite paranoid now...

[1] 3 types of tables:  ~40%=8.5M rows; ~40%=33M rows; ~20%=varying sizes

Thanks,
Pierre 



pgsql-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: pg_reload_conf()
Next
From: Tom Lane
Date:
Subject: Re: pg_dump'ed file contains "DROP DATABASE"