1. 程式人生 > >oracle指定訪問某表或某檢視

oracle指定訪問某表或某檢視

在oracle中,想建立一個賬號,然後只能只讀地訪問指定的表,怎麼搞?

一、為特定的表建立檢視
建立檢視的時候還可以加上過濾條件,連訪問哪些資料都可以指定。

create or replace view bigboss.v_User as
    select * from bigboss.user
        where u_groupid in (select pm_unitid from bigboss.group where qh like '46%');

create or replace view bigboss.v_Group as
    select * from
bigboss.group where qh like '46%';

二、建立賬號
並賦許可權。許可權小小的,夠用就行。

create user sso identified by 123456;

grant connect to sso;

grant select on bigboss.v_user to sso;
grant select on bigboss.v_group to sso;

grant create synonym  to sso;

三、新賬號小試牛刀
在新賬號下,

create or replace synonym v_user for bigboss.v_user;
create or replace synonym v_group for bigboss.v_group;

如此,新賬號sso即可愉快無礙地訪問那倆檢視了:

select * from v_user;
select * from v_group;