Subject: Re: Identify system databases

From: Adrian Klaver <[email-masked]>
Date: Tue, 15 Apr 2025 08:07:57 -0700

On 4/15/25 07:48, Igor Korot wrote:
> Hi, ALL,
> Is there a field in the pg_databases table which indicates that 
> particular DB is a system one?

No there is not. As a practical matter they are no different then any 
user created database, other then template0 is created with datallowconn 
  set to false.

> 
> Or it can be determined ony by name?
> 
> Thank you.
> 

-- 
Adrian Klaver
[email-masked]

---

From: Igor Korot <[email-masked]>
Date: Tue, 15 Apr 2025 11:21:34 -0500

---------- Forwarded message ---------
From: Igor Korot <[email-masked]>
Date: Tue, Apr 15, 2025 at 11:16 AM
Subject: Re: Identify system databases
To: Adrian Klaver <[email-masked]>

Hi, Adrian,

> user created database, other then template0 is created with datallowconn

Understood. Will filter by name…

Thank you.

---

From: Tom Lane <[email-masked]>
Date: Tue, 15 Apr 2025 12:29:56 -0400

> user created database, other then template0 is created with datallowconn 

Yeah; in a very real sense there isn't such a thing as a "system
database" in Postgres.  There are pre-created databases that have
specific uses (such as being the default template for CREATE
DATABASE), but those uses are identified by name not by OID.
You can drop template1, and the only thing that will be unhappy
is CREATE DATABASE, and if you make a new DB that is named
template1 then CREATE DATABASE will be happy again.

			regards, tom lane