Oracle权限的分配与回收

Oracle权限的分配:
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 用户"
-------------------------------------------------------------------------------
系统权限不能级联回收,对象权限可以级联回收。

-------------------------------------------------------------------------------------

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/aa579ce95987b7c9e2b432d029cd9c3a.html