简体   繁体   中英

How is the Postgres 'system database' attribute set or unset?

One of several databases in a Postgres 10.15 cluster has been set to be a system database. The mechanism that caused this is unknown, though it may have happened at the same time that the database was converted to a template by updating the pg_database table. The pg_database table does not have a setting to control whether or not a database is a system database, however, and I cannot find any documentation describing how to set (or unset, which is what I really want to do) the system database flag.

The idea of a “system database” is foreign to PostgreSQL, it is an artifact of pgAdmin.

PostgreSQL does have the notion of a “template database”, that is a database that is intended to serve s template in CREATE DATABASE . You turn a database to a template database with

ALTER DATABASE some_db IS_TEMPLATE TRUE;

For such a database it is also a good idea to forbid connections, because you can only use a database as template if nobody else is connected to it:

ALTER DATABASE some_db ALLOW_CONNECTIONS FALSE;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM