role.md 857 字节
Newer Older
M
Mars Liu 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
# 角色

你是 rental dvd 公司的数据库管理员,公司数据分析组有 Fred、Alice、James、Jone 四位成员,现在你需要给数据分析组授权,允许他们
查询 trade 数据库的 public schema 中的所有表,规范的操作应该是

## 答案

```postgresql
create role analysis;
grant analysis to fred, alice, james, jone;
grant select on all tables in schema public to analysis;
```

## 选项

### 将来人员变动管理会很繁琐

```postgresql
grant select on all tables in schema public to fred, alice, james, jone;
```

### 过度授权

```postgresql
create role analysis;
grant analysis to fred, alice, james, jone;
grant all on all tables in schema public to analysis;
```

### 语句不完整

```postgresql
create role analysis;
grant analysis to fred, alice, james, jone;
grant select on all to analysis;
```