Is `pg_user` a view or a catalog?

≯℡__Kan透↙ 提交于 2019-12-11 07:29:02

问题


From https://www.postgresql.org/docs/9.5/static/view-pg-user.html under "System Catalogs"

The view pg_user provides access to information about database users. This is simply a publicly readable view of pg_shadow that blanks out the password field.

Is pg_user a view or a catalog?

  • pg_user is described under "System Catalogs" in the postgresq manual, which seems to suggest pg_user is a catalog/database. ( Am I correct that a catalog is the same concept as a database? (I learned this from a highly upvoted post)?)

  • But the quote calls pg_user a view. Which database's view is pg_user? I didn't find the answer in the link, but I have seen pg_catalog.pg_user works. But pg_catalog is not a catalog or database, but a schema of any database.

Thanks.


回答1:


Unfortunately all of these terms are overloaded.

It is like how a 'schema' can be either the namespace itself, or the definition of all of the objects which exist inside that namespace.

A 'catalog' is either the database itself (which is a terminology adopted by the SQL standards committee, which everyone but them seems to regret), or it is a table or view which lets you introspect into the structure of that database.

So 'view' describes its implementation, while 'catalog' describes its purpose.

In this case it is a bit more confusing because pg_user is a shared catalog (or at least, it is view over shared catalog tables). It is shared between all the databases in the cluster, as PostgreSQL users are not created per-database but are cluster-wide.



来源:https://stackoverflow.com/questions/50882949/is-pg-user-a-view-or-a-catalog

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!