Home > php教程 > php手册 > DB2用户表批量授权

DB2用户表批量授权

WBOY
Release: 2016-06-13 08:51:41
Original
1176 people have browsed it

DB2用户表批量授权


一、新建用户
[root@localhost ~]# passwd ghan
Changing password for user ghan.
New UNIX password:
BAD PASSWORD: it is too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@localhost ~]# su - db2inst2
[db2inst2@localhost ~]$ db2 connect to ghan user ghan
输入 ghan 的当前密码:


数据库连接信息


数据库服务器 = DB2/LINUXX8664 9.7.5
SQL 授权标识 = GHAN
本地数据库别名 = GHAN


二、访问db2int2.t2表报错

[db2inst2@localhost ~]$ db2 "select count(1) from db2inst2.t2"
SQL0551N "GHAN" 不具有对对象 "DB2INST2.T2" 执行操作 "SELECT"
的必需权限或特权。 SQLSTATE=42501



[db2inst2@localhost ~]$ db2 connect to ghan


数据库连接信息


数据库服务器 = DB2/LINUXX8664 9.7.5
SQL 授权标识 = DB2INST2
本地数据库别名 = GHAN

三、生成授权脚本
[db2inst2@localhost ~]$ db2 -x +o -z commands.sql "select 'grant select,insert, update, delete on table ' || trim(tabschema) || '.' || trim(tabname) || ' to user ghan;' from syscat.tables where type = 'T'"
四、修改指写表授权
[db2inst2@localhost ~]$ vi commands.sql

****略***

五、执行授权语句
[db2inst2@localhost ~]$ db2 -tsvf commands.sql
grant select,insert, update, delete on table DB2INST2.EMPL to user ghan
DB20000I SQL 命令成功完成。


grant select,insert, update, delete on table DB2INST2.EMPLDD to user ghan
DB20000I SQL 命令成功完成。


grant select,insert, update, delete on table DB2INST2.STAFF to user ghan
DB20000I SQL 命令成功完成。


grant select,insert, update, delete on table DB2INST2.T1 to user ghan
DB20000I SQL 命令成功完成。



[db2inst2@localhost ~]$ db2 connect to ghan user ghan
输入 ghan 的当前密码:


数据库连接信息


数据库服务器 = DB2/LINUXX8664 9.7.5
SQL 授权标识 = GHAN
本地数据库别名 = GHAN

六、测试授权结果

[db2inst2@localhost ~]$ db2 "select count(*) from db2inst2.t1"


1
-----------
4


1 条记录已选择。
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template