Re: Identify system databases

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: Igor Korot <ikorot01(at)gmail(dot)com>, "pgsql-generallists(dot)postgresql(dot)org" <pgsql-general(at)lists(dot)postgresql(dot)org>
Subject: Re: Identify system databases
Date: 2025-04-15 16:29:56
Message-ID: 1699115.1744734596@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> writes:
> On 4/15/25 07:48, Igor Korot wrote:
>> 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.

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2025-04-15 16:30:56 Re: Fwd: Identify system databases
Previous Message Igor Korot 2025-04-15 16:21:34 Fwd: Identify system databases