授予用户db。*的所有特权?

时间:2020-08-09 17:52:22

标签: postgresql privileges grant

(选择PostgreSQL 11.6,由Visual C ++ build 1800 64位编译)

我创建了一个新用户:

create user bob with password 'some_password_string';

我在一个名为“ GoogleData”的数据库中:

grant all privileges on GoogleData to bob;

SQL Error [42P01]: ERROR: relation "googledata" does not exist

例如,我可以通过指定schema.table将bob添加到GoogleData中的特定表中。

grant all privileges on reporting.ecom_dashboard to bob;

那行得通,除了有太多的表无法一一授予访问权限。我也无法授予公众访问权限。

尝试:

grant all privileges on public to bob;
SQL Error [42P01]: ERROR: relation "public" does not exist

尝试遍历特定模式,如下所示:

grant all privileges on reporting.* to bob;
SQL Error [42601]: ERROR: syntax error at or near "to"
  Position: 46
  1. 如何在数据库级别授予Bob的所有特权?尝试时出现错误“错误:关系“ googledata”不存在”(其中googledata是所讨论的数据库)
  2. 如果我似乎无法在数据库级别授予访问权限,那么如何在模式级别grant all privileges on schema_name.* to bob;授予bob特权?

1 个答案:

答案 0 :(得分:1)

如何在架构级别授予bob特权

您正在寻找选项on all tables in schema

grant all privileges on all tables in schema public to bob;
grant all privileges on all tables in schema reporting to bob;

您可能还想change the default privileges,以便将来也可以将其应用于表。