什么是 PostgreSQL 表所有者?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33841647/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 02:05:34  来源:igfitidea点击:

What is a PostgreSQL table owner?

postgresql

提问by Jonathan Ginsburg

I am unsure about what does a PostgreSQLtable owner means. I notice that it changes an attribute of the table itself and not about the owner because it is specified through an

我不确定PostgreSQL表所有者是什么意思。我注意到它更改了表本身的属性而不是关于所有者的属性,因为它是通过

ALTER TABLE table_name OWNER TO role_name;

回答by Scirocco

You can see who is owner in certain table:

您可以在某些表中看到谁是所有者:

select * from pg_tables where tablename = 'my_tbl';

or you can see all tables by certain owner:

或者您可以查看某个所有者的所有表:

select * from pg_tables where tableowner = 'username';

回答by a_horse_with_no_name

The owner is (if nothing else happened) the user (role) that createdthe table. So if user arthurruns create table foo (id integer), arthurownsthe table.

所有者是(如果没有其他事情发生)创建表的用户(角色)。因此,如果用户arthur运行create table foo (id integer),则arthur拥有该表。

The owner of a table has all privileges on it - including the privilege to drop it. Or the privilege to grant otherusers (roles) access to the table.

表的所​​有者拥有它的所有权限——包括删除它的权限。或者授予其他用户(角色)访问表的权限。

The SQL script generated by pg_dumptypically includes the alter table set owner ...statement as those scripts are intended to be run by the DBA and in that case all tables would be owned by the DBA - which means the "real" owner could not change or access the tables.

生成的 SQL 脚本pg_dump通常包括alter table set owner ...语句,因为这些脚本旨在由 DBA 运行,在这种情况下,所有表都将由 DBA 拥有——这意味着“真正的”所有者无法更改或访问这些表。