权限的分配:
1、grant用于将角色、系统权限、对象权限赋予用户、角色。
2、赋权的前提条件:
系统权限:有"grant any privilege"的系统权限、被授予该系统权限时使用了 "admin option"
角色权限:1)授予角色角色权限时带有"admin option";2)被授予了"grant any role"的系统权限;3)是角色的创建者。
对象权限:1)是对象的拥有者;2)被授予对象权限时带有"grant option";3)被授予了"grant any object privilege"权限;
3、语法:
grant [grant_system_privileges|grant_object_privileges];
grant_system_privileges:
{ system_privilege| role| ALL PRIVILEGES}
[, { system_privilege| role| ALL PRIVILEGES}]...
TO grantee_clause [ WITH ADMIN OPTION ];
grantee_clause:
{ user [ IDENTIFIED BY password ]| role| PUBLIC}
[, { user [ IDENTIFIED BY password ]| role| PUBLIC}]...
grant_object_privileges:
{ object_privilege | ALL [ PRIVILEGES ] }
[ (column [, column ]...) ]
[, { object_privilege | ALL [ PRIVILEGES ] }[ (column [, column ]...) ]]...
on_object_clause TO grantee_clause [ WITH HIERARCHY OPTION ][ WITH GRANT OPTION ]
on_object_clause:
ON { [ schema. ] object
| DIRECTORY directory_name
| EDITION edition_name
| MINING MODEL [schema.] mining_model_name
| JAVA { SOURCE | RESOURCE } [ schema. ] object
}
要记住"grant 权限 to 用户".
---------------------------------------------------------------------------------------
权限的回收:
1、语法
REVOKE { revoke_system_privileges| revoke_object_privileges} ;
revoke_system_privileges:
{ system_privilege| role| ALL PRIVILEGES}
[, { system_privilege
| role
| ALL PRIVILEGES
}
]...
FROM grantee_clause
revoke_object_privileges:
{ object_privilege | ALL [ PRIVILEGES ] }
[, { object_privilege | ALL [ PRIVILEGES ] } ]...
on_object_clause
FROM grantee_clause
[ CASCADE CONSTRAINTS | FORCE ]
grantee_clause:
{ user [ IDENTIFIED BY password ]
| role
| PUBLIC
}
[, { user [ IDENTIFIED BY password ]
| role
| PUBLIC
}
]...
on_object_clause:
ON { [ schema. ] object
| DIRECTORY directory_name
| EDITION edition_name
| MINING MODEL [schema.] mining_model_name
| JAVA { SOURCE | RESOURCE } [ schema. ] object
}
记住"revoke 权限 from 用户"
-------------------------------------------------------------------------------
系统权限不能级联回收,对象权限可以级联回收。
-------------------------------------------------------------------------------------
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。