db2用户权限赋予

id xxx
sudo su - xxxx
date
db2 list db directory
db2 connect to xxxxx
db2 "select * from syscat.dbauth where grantee = 'xxx'" |tr -s " "
db2 "select * from syscat.tabauth where grantee = 'xxx'" |tr -s " "
db2 "GRANT connect ON DATABASE TO xxx"
db2 "select * from syscat.dbauth where grantee = 'xxx'" |tr -s " "


for TABLE in `db2 connect to xxxx> /dev/null; 
db2 list tables for all show detail | grep -v "Table/View" | grep -v "\-\-" | grep -v "^$" | grep -i "^[a-z]" | awk '{print "\""$2"\"""."$1}'`;do
db2 grant select on table $TABLE to user xxx
done

db2 "select * from syscat.tabauth where grantee = 'xxx'" |tr -s " "
db2 terminate

date


注意查询语句里的用户id是大写

猜你喜欢

转载自blog.csdn.net/shuryuu/article/details/80604702
今日推荐