mysql 用户添加查询视图权限_把视图查询权限授予普通用户

对于一些oracle的普通用户需要查询某个视图,但是因为安全考虑不能把dba权限赋予普通用户,那只能把相关视图的查询权限赋予给普通用户,下面就来说一下怎么给普通用户授予视图的查询权限。

1.给用户授予某个视图的查询权限

SQL> grant select on v$mystat to test1;

grant select on v$mystat to test1

*

ERROR at line 1:

ORA-02030: can only select from fixed tables/views

这个错误可能很多人都遇到过,为什么会报这个错误呢?因为v$这类我们经常查的视图都是v_$开头视图的同义词。

select synonym_name,table_name from dba_synonyms where synonym_name='V$MYSTAT';

SYNONYM_NAME                   TABLE_NAME

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

V$MYSTAT                       V_$MYSTAT

所以我们需要直接授予用户v_$的查询权限

SQL> grant select on v_$mystat to test1;

Grant succeeded.

##这样 test1用户就拥有了 查询v$mystat视图的权限了

收回权限

revoke select on v_$mystat from test1;

2.给用户授予select anydictionary权限

SQL> grant select any dictionary to test1;

Grant succeeded.

##给用户授予select any dictionary 权限,那么用户就能访问所有的视图,不要轻易给普通用户授予该权限。

3.给public 授予某个视图的查询权限

SQL> grant select on v_$database to test1;

Grant succeeded.

##这样数据库里所有的用户都具有查询v$database视图的权限了

4.给用户授予select any table 权限

##如果把该权限赋予给某用户,并且数据库O7_DICTIONARY_ACCESSIBILITY参数值为true,那么用户可以查询数据库里的所有表,视图等,不要赋予普通用户()

5.查看用户权限

select * from dba_sys_privs where grantee='TEST1';

select * from dba_tab_privs where grantee='TEST1';

select * from dba_role_privs where grantee='TEST1';

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值