提交 a5be91aa 编写于 作者: M Mars Liu

grant and revoke

上级 d2ed176e
......@@ -2,5 +2,6 @@
"type": "code_options",
"author": "刘鑫",
"source": "create_table.md",
"notebook_enable": false
"notebook_enable": false,
"exercise_id": "14cc4d8de8c44415b80e9c94ea617464"
}
\ No newline at end of file
......@@ -2,5 +2,6 @@
"type": "code_options",
"author": "刘鑫",
"source": "serial.md",
"notebook_enable": false
"notebook_enable": false,
"exercise_id": "69bcc5f08a4e4328b54e389d74363e2a"
}
\ No newline at end of file
......@@ -2,5 +2,6 @@
"type": "code_options",
"author": "刘鑫",
"source": "table.md",
"notebook_enable": false
"notebook_enable": false,
"exercise_id": "17b32ec3157e4b7aaa6948fa04db51e3"
}
\ No newline at end of file
......@@ -2,5 +2,6 @@
"type": "code_options",
"author": "刘鑫",
"source": "function.md",
"notebook_enable": false
"notebook_enable": false,
"exercise_id": "7d0a6977f12a4d93bd684b56b2ad7003"
}
\ No newline at end of file
{
"type": "code_options",
"author": "刘鑫",
"source": "grant.md",
"notebook_enable": false
}
\ No newline at end of file
# 授权
管理员要给用户 fred 授权,允许他查询 emplyee 表,应用哪一条语句?
## 答案
```postgresql
grant select on table employee to fred;
```
## 选项
### 权限名错误
```postgresql
grant query on table employee to fred;```
```
### 权限名错误
```postgresql
grant read on table employee to fred;```
```
### 操作关键词错误
```postgresql
grant select on table employee of fred;```
```
### 操作错误
```postgresql
grant select on table employee.* of fred;```
```
### 权限过高
```postgresql
grant all on table employee to fred;```
```
# 撤销权限
数据组的 Fred 调到了研发团队,不再参与分析生产数据,现在管理员要收回他对 trade 表的查询权限,假设这个权限是授予他本人的数据库
用户 fred ,下面哪个操作是对的?
## 答案
```postgresql
revoke select on trade from fred;
```
## 选项
### 操作错误
```postgresql
grant not select on trade to fred;
```
### 操作关键字错误
```postgresql
revoke select on trade to fred;
```
### 指定权限错误
```postgresql
revoke owned trade from fred;
```
# 角色
你是 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;
```
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册