问题
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 suggestpg_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 ispg_user
? I didn't find the answer in the link, but I have seenpg_catalog.pg_user
works. Butpg_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