只对某一张表给user1用户赋权查询权限大约的步骤:
1,新建个数据库账号;
create user user1 with password 'GBase123';
2,在要授权的库里(示例使用testdb),使用gbasedbt用户回收所有表的public权限;
-- 所有的表
dbaccess testdb -;
revoke all on TABNAME from public;
或者使用下面的生成的脚本dbaccess testdb revoke.sql
3,授予用户usre1访问库及表的权限;
dbaccess testdb -
grant connect to testdb;\-- 所有的表都执行
grant select on TABNAME to user1;
============================================================================================
如果要对数据库中所有的表给user1用户只赋权select权限的操作步骤如下:
1,新建个数据库账号user1(首先登录到对应的数据库里面,例如testdb数据库);
dbaccess testdb -
create user user1 with password 'GBase123';
grant connect to user1;
2, 生成回收权限语句及授权语句
dbaccess testdb -
unload to revoke.sql delimiter ';'
select 'revoke all on ' || tabname || ' from public'
from systables
where tabid > 99
and tabtype = 'T';
unload to grant.sql delimiter '; '
select 'grant select on ' || tabname || ' to user1'
from systables
where tabid > 99
and tabtype = 'T';
3,执行回收权限和赋权只能查询的语句(使用gbasedbt用户)
dbaccess testdb revoke.sql
dbaccess testdb grant.sql
执行完上面两个语句后用户user1就只有select权限了