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