1. 授權:grant
1.1 命令
grant <權限> [,<權限>]...
on <對象類型> <對象名> [,<對象類型 > <對象名>]...
to <用戶> [,<用戶>]...
[with grant option];
1.2 例子
- 例1
把查詢Student表的權限授給用戶U1。
grant select
on table Student
to U1;
- 例2
把Student全部操作權限授予用戶U2和U3。
grant all privileges
on table Student
to U2,U3;
- 例3
把插入Student和Course表權限授予用戶U4,並允許將此權限再授予其他用戶。
grant insert
on table Student,Course
to U4
with grant option;
- 例4
把查詢Student表權限授予所有用戶。
grant select
on table Student
to public;
2. 回收revoke
2.1 命令
revoke <權限> [,<權限>]...
on <對象類型 > <對象名> [,<對象類型 > <對象名>]...
from <用戶> [,<用戶>]...
[cascade | restrict];
2.2 例子
- 例1
回收U1對Student的查詢權限
revoke select
on Table Student
from U1;
- 例2
回收所有用戶對Student,Course的插入權限
revoke insert
on table Student,Course
from public;
- 例3
回收U2對Student的查詢權限,並級聯回收其授權其它用戶查詢Student的權限。
revoke select
on table Student
from U2 cascade;
3. 參考博客
- https://blog.csdn.net/liuwengai/article/details/51321198?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task
- https://blog.csdn.net/u011296485/article/details/77141234?depth_1-utm_source=distribute.pc_relevant.none-task&utm_source=distribute.pc_relevant.none-task