观前提示:此贴仅适用于那些已经学习过标准sql,但因为久不使用忘记书写格式的读者。
1.对表的权限授予:
总格式:
grant select,update([a属性],[b属性]),insert / all privilegs
on table [s表],[c表]
to [用户1],[用户2] / public
with grant option
注:[ ]这个符号里的内容,包括[ ],均可被替换
例1:
把Student表的权限授予给用户u1
grant select
on table Student
to U1
例2:
把Student表和Course表的全部操作权限授予用户U2,U3
grant all privilegs
on table Student,Course
to U2,U3
例3:
把对表SC的查询权限授予所有的用户
grant select
on table SC
to public
例4:
把查询Student表和修改学生学号的权限授给用户U4
grant select,update(sno)
on table Student
to U4
例5:
把对表SC的insert权限授予给U5用户,并允许将此权限再授予其他用户
grant inert
on table SC
to U5
with grant option
例6:
执行上面语句后,U5不仅拥有了对表SC的insert权限,还可以将传播它得到的权限,即由U5用户发上述grant命令给其他用户,现在U5把权限授予给U6,如下是U5发出的命令
grant insert
on table SC
to U6
with grant option
如果U7未被授予传播权限,则U7不能授权给U8。
2.对表权限的收回
总格式:
revoke select,update([a属性],[b属性]),insert / all privilegs
on table [s表],[c表]
from to [用户1],[用户2] cascade / public
(注:cascade表示级联操作)
例子就不再写了,和权限授予的语法思路完全一致。
如果您觉得此文章对您有所帮助,请点一下赞支持作者,感谢!