微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

postgresql – 什么是特殊数据库“postgres”?

我有一个Postgresql服务器,上面运行着几个数据库.其中一个数据库叫做postgres,它从一开始就存在.我在里面看不到任何表格,我从未明确地使用它,但我注意到,任何用户都可以在数据库中创建表格(这不是我想要的 – 我不希望除管理员之外的任何用户创建任何表格.)

我觉得它是某种特殊的数据库,是服务器正常运行所必需的,但它的目的究竟是什么呢?内部存储(或可能存储)哪种数据?它是否包含有关其他数据库的元数据(例如information_schema?).如果我从公共中撤销对此数据库的连接权限,是否会发生令人讨厌的事情?或者,如果我甚至放弃它?

我用谷歌搜索了半个小时,但总是得到完全不相关的东西,因为postgres这个词也用于用户postgres和DBMS本身.

没什么特别的.如Postgresql文档 Creating a Database中所述,您需要连接到数据库,以便创建另一个

Since you need to be connected to the database server in order to execute the CREATE DATABASE command,the question remains how the first database at any given site can be created. The first database is always created by the initdb command when the data storage area is initialized. (See Section 17.2.) This database is called postgres. So to create the first “ordinary” database you can connect to postgres.

Template Databases

Note: template1 and template0 do not have any special status beyond the fact that the name template1 is the default source database name for CREATE DATABASE. For example,one Could drop template1 and recreate it from template0 without any ill effects. This course of action might be advisable if one has carelessly added a bunch of junk in template1. (To delete template1,it must have pg_database.datistemplate = false.)

The postgres database is also created when a database cluster is initialized. This database is meant as a default database for users and applications to connect to. It is simply a copy of template1 and can be dropped and recreated if necessary.

原文地址:https://www.jb51.cc/postgresql/192443.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐