1. 授权:grant
1.1 命令
复制代码
1
2
3
4
5grant <权限> [,<权限>]... on <对象类型> <对象名> [,<对象类型 > <对象名>]... to <用户> [,<用户>]... [with grant option];
1.2 例子
- 例1
把查询Student表的权限授给用户U1。
复制代码
1
2
3
4grant select on table Student to U1;
- 例2
把Student全部操作权限授予用户U2和U3。
复制代码
1
2
3
4grant all privileges on table Student to U2,U3;
- 例3
把插入Student和Course表权限授予用户U4,并允许将此权限再授予其他用户。
复制代码
1
2
3
4
5grant insert on table Student,Course to U4 with grant option;
- 例4
把查询Student表权限授予所有用户。
复制代码
1
2
3
4grant select on table Student to public;
2. 回收revoke
2.1 命令
复制代码
1
2
3
4
5revoke <权限> [,<权限>]... on <对象类型 > <对象名> [,<对象类型 > <对象名>]... from <用户> [,<用户>]... [cascade | restrict];
2.2 例子
- 例1
回收U1对Student的查询权限
复制代码
1
2
3
4revoke select on Table Student from U1;
- 例2
回收所有用户对Student,Course的插入权限
复制代码
1
2
3
4revoke insert on table Student,Course from public;
- 例3
回收U2对Student的查询权限,并级联回收其授权其它用户查询Student的权限。
复制代码
1
2
3
4revoke 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
最后
以上就是端庄中心最近收集整理的关于SQL中的授权grant与回收revoke的全部内容,更多相关SQL中内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复