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 1osspl-0003IH-6z for pgsql-admin@arkaria.postgresql.org; Wed, 09 Nov 2022 21:42:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1osspj-0003yl-Nv for pgsql-admin@arkaria.postgresql.org; Wed, 09 Nov 2022 21:42:07 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1osspj-0003yb-Cm for pgsql-admin@lists.postgresql.org; Wed, 09 Nov 2022 21:42:07 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ossph-00038C-89 for pgsql-admin@lists.postgresql.org; Wed, 09 Nov 2022 21:42:06 +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 2A9Lg3Uv037464; Wed, 9 Nov 2022 16:42:03 -0500 From: Tom Lane To: "David G. Johnston" cc: Ron , pgsql-admin@lists.postgresql.org Subject: Re: vacuumdb maintenance-db?? In-reply-to: References: <36bb2141-52e0-e75a-ea4a-5f2236b76c26@gmail.com> <92175f50-42f4-bb90-83cd-02b3407c0b56@gmail.com> Comments: In-reply-to "David G. Johnston" message dated "Wed, 09 Nov 2022 14:17:39 -0700" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <37462.1668030123.1@sss.pgh.pa.us> Date: Wed, 09 Nov 2022 16:42:03 -0500 Message-ID: <37463.1668030123@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk "David G. Johnston" writes: > On Wed, Nov 9, 2022 at 1:54 PM Ron wrote: >> But this raises a different question: when does the postgres database not >> exist? > You are giving it too much specialness. Both ALTER DATABASE ... RENAME and > DROP DATABASE can be used on it. The template databases aren't all that special either. There is a defense against dropping them accidentally: regression=# drop database template1; ERROR: cannot drop a template database but you can override that if you really mean it: regression=# alter database template1 with is_template false; ALTER DATABASE regression=# drop database template1; DROP DATABASE This might seem pretty scary, but it's intentional, per the comments in IsPinnedObject: * Databases are never pinned. It might seem that it'd be prudent to pin * at least template0; but we do this intentionally so that template0 and * template1 can be rebuilt from each other, thus letting them serve as * mutual backups (as long as you've not modified template1, anyway). regards, tom lane