DB2的权限(authorization)

db2的权限是以层次结构的形式体现的,用于将一组预先确定的权限授予用户账户组。

DB2中包括两类权限:实例权限和数据库权限

实例权限包括:SYSADM, SYSCTRL, SYSMAINT, SYSMON等,权限范围包括实例级命令 和 针对该实例所有数据库的命令,通过DBM CFG文件分给组, 这些权限且只能分配给组。

数据库权限包括:DBADM, SECADM, LOAD这三种权限,可以通过GRANT分配给用户或用户组。

其中SYSCTRL、SYSMAINT、SYSMON权限级别的用户不能访问数据,DBAMD、LOAD权限级别的用户可以访问数据。




SQL SERVER 赋予用户查询指定DB中所有表的命令 db2给用户赋予查询的权限_数据库

                                                                                   


  

                                                                                                   权限图

查看当前权限:

1)db2 connect to test 连上数据库

2) db2ilist 查看所有实例

3)db2 get instance 查看当前数据库所在实例

4)db2 get authorizations 查看自己拥有的权限


SYSADM: DB2 UDB中最高的管理权限级别,可以发出数据库管理器(实例)和数据库命令,及访问数据库管理器实例中任何数据库任何表中的数据,一句话:什么都能做。

                 该权限供对需要使用程序和数据的完全访问权的DB2 UDB管理员使用。

SYSCTRL:最高的系统控制权限级别,提供对数据库管理器实例及其数据库执行维护和管理操作的能力,但不允许访问数据库中的数据。

                    该权限供管理一个包含敏感数据的数据库管理器实例的用户使用。(仅管理一个实例(包含实例中的数据库),并且不能access数据库中的数据)

SYSMAINT: 比SYSCTRL低一个级别,提供对数据库管理器实例及其数据库执行维护和管理操作的能力,但不允许访问数据库中的数据。

中的数据库的用户使用。   

SYSMON:提供获得数据库管理器实例及快照的功能。该权限不允许改变系统资源的使用。

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

SECADM 权限是对特定数据库的安全性管理权限。此权限允许您创建和管理与安全性相关的数据库对象以及授予和撤销所有数据库权限和特权。此外,安全性管理员可以执行审计系统例程以及管理还有哪些用户可以执行审计系统例程。SECADM 权限能够从目录表和目录视图中进行选择,但是无法访问存储在用户表中的数据。SECADM 权限只能由安全性管理员(拥有 SECADM 权限)授予,并且可授予用户、组或角色。PUBLIC无法直接或间接获取 SECADM 权限。数据库必须至少有一个具备 SECADM 权限的 USER 类型的授权标识。无法从 USER 类型的每个授权标识撤销 SECADM 权限。



DBADM: 对一个实例中的特定数据库的次高管理权限级别,允许用户运行某些实用程序,发出数据库命令及访问数据库中表的数据。

                该权限供需要完全访问数据库对象和数据,但是不需要完整的维护权限的管理员使用。(一般用于开发人员)

LOAD: 允许用户调用LOA实用程序。

             该权限供只想批量load一组新数据的用户使用。



=======================================================DB2 10.1


Instance level authorities



  • SYSADM -for users managing the instance as a whole
  • SYSCTRL -for users administering a database manager instance
  • SYSMAINT -for users maintaining databases within an instance
  • SYSMON -for users monitoring the instance and its databases



A user with a higher-level authority also has the abilitiesgiven by the lower level authorities. For example, a user with SYSCTRLauthority can perform the functions of users with SYSMAINT and SYSMONauthority as well.



Figure 1. Instance-level authorities




Database level authorities


  • SECADM - for users managing security within a database
  • DBADM - for users administering a database
  • ACCESSCTRL - for users who need to grant and revoke authoritiesand privileges (except for SECADM, DBADM, ACCESSCTRL, and DATAACCESSauthority, SECADM authority is required to grant and revoke theseauthorities)
  • DATAACCESS - for users who need to access data
  • SQLADM - for users who monitor and tune SQL queries
  • WLMADM - for users who manage workloads
  • EXPLAIN - for users who need to explain query plans (EXPLAIN authoritydoes not give access to the data itself)


The following diagram shows, where appropriate, whichhigher level authorities include the abilities given by a lower levelauthority. For example, a user with DBADM authority can perform thefunctions of users with SQLADM and EXPLAIN authority, and all functionsexcept granting USAGE privilege on workloads, of users with WLMADMauthority.


Figure 2. Database-level authorities