
假设IQ数据库中abcuser创建了应用的表,我们希望创建一个用户user1,让这个用户能够只读访问abcuser创建的表。实现方法如下:
(1) 创建abcuser用户(用DBA用户或具有DBA权限的用户执行)
grant connect,resource to "abcuser" identified by "pwd123"
(2) 创建表,并插入数据 ( 用abcuser登陆执行 )
create table customer(id int,name char(8))
insert into customer values(1,'abc')
commit
(3) 创建与表属主用户同名的组(用DBA用户或具有DBA权限的用户执行)
grant group to "abcuser"
(4) 创建用户user1(用DBA用户或具有DBA权限的用户执行),并授权
grant connect to "user1" identified by "pwd123"
grant membership in group "abcuser" to "user1" ---让user1属于abcuser组
grant select on abcuser.customer to user1--把abcuser用户创建的表的查询权限赋予user1
(5) 用户user1登陆,执行查询
select * from customer --ok
insert into customer values(2,'aaa') --error 没有权限执行。
在实际项目中,如果打算对已有IQ数据库实现这一目标,那么可以省略上面的(1),(2)步,直接从(3)步开始,假设你们让user1作为只读查询用户:
grant group to "abcuser"
grant connect to "user1" identified by "pwd123"
grant membership in group "abcuser" to "user1"
grant select on abcuser.table1 to user1
grant select on abcuser.table2 to user1
grant select on abcuser.table3 to user1
grant select on abcuser.table4 to user1
注意:
(1) 需要为abcuser创建的每一个希望user1只读访问的表都要执行 grant select语句
(2) 如果abcuser拥有的表有很多,那么需要编写脚本进行授权。或者使用DBAssistant工具,成批选择或全部选择进行授权。
首先打开“数据“选择“添加新数据源”然后(数据库)下一步,(数据集)下一步,选择”新建连接“,依次选择服务器名,服务器验证方式,选择”选择或输入一个数据库名,添加刚刚新建的数据库,然后点击“测试连接”,看看数据库连接是否成功。成功后点“确定”回到“数据源配置向导”页面,将“连接字符串复制下来,然后”下一步“,勾选”表“最后点”完成”结束全部 *** 作。欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)