Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nAm7s-0006Tx-HO for pgsql-admin@arkaria.postgresql.org; Fri, 21 Jan 2022 05:06:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nAm7q-0008Fg-K9 for pgsql-admin@arkaria.postgresql.org; Fri, 21 Jan 2022 05:06:14 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nAm4m-0003DX-9r for pgsql-admin@lists.postgresql.org; Fri, 21 Jan 2022 05:03:04 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nAm4j-0008Bf-TG for pgsql-admin@postgresql.org; Fri, 21 Jan 2022 05:03:03 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 20L52wON1123451; Fri, 21 Jan 2022 00:02:58 -0500 From: Tom Lane To: Wells Oliver cc: pgsql-admin Subject: Re: pg_dump -n schema -Fc has a DROP DATABASE command... confused In-reply-to: References: Comments: In-reply-to Wells Oliver message dated "Thu, 20 Jan 2022 20:44:26 -0800" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1123449.1642741378.1@sss.pgh.pa.us> Date: Fri, 21 Jan 2022 00:02:58 -0500 Message-ID: <1123450.1642741378@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Wells Oliver 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