Re: Fwd: Identify system databases

Поиск
Список
Период
Сортировка
От Adrian Klaver
Тема Re: Fwd: Identify system databases
Дата
Msg-id 817abeac-d628-4279-bfef-9e1e3aa1884b@aklaver.com
обсуждение исходный текст
Ответ на Fwd: Identify system databases  (Igor Korot <ikorot01@gmail.com>)
Ответы Re: Fwd: Identify system databases
Список pgsql-general
On 4/15/25 09:21, Igor Korot wrote:
> 
> 

> Hi, David,
> 
> On Tue, Apr 15, 2025 at 9:56 AM David G. Johnston 
> <david.g.johnston@gmail.com <mailto:david.g.johnston@gmail.com>> wrote:
> 
>     On Tuesday, April 15, 2025, Igor Korot <ikorot01@gmail.com
>     <mailto:ikorot01@gmail.com>> wrote:
> 
>         Hi, ALL,
>         Is there a field in the pg_databases table which indicates that
>         particular DB is a system one?
> 
> 
>     What is a system database?
> 
> 
> I consider system database a database that is created by default when 
> the server is run for the first time.

Agreed.

The fact that initdb creates the template0, template1 and postgres 
databases and you can't change that makes them system not user databases.

Further from here:

https://www.postgresql.org/docs/devel/app-initdb.html

"The postgres database is a default database meant for use by users, 
utilities and third party applications"

indicates that postgres is expected to be in a cluster(system).

Lastly the CREATE DATABASE depends on template1 to be there to create at 
least the first user database. Also template0 is a "clean" template 
database that allows for using a new encoding in new database. It is 
also used by pg_dump/restore:

CREATE DATABASE test WITH TEMPLATE = template0 ...

> 
> Kind of a predefined set of databases…
> 
> As an example - there is a database called Postgres. It is created when 
> the server runs for the first time, whether I as a user like it or not.
> 
> Thank you.
> 
> 
>     David J.
> 

-- 
Adrian Klaver
adrian.klaver@aklaver.com




В списке pgsql-general по дате отправления: