1、现象
(1)创建用户a,授权为dba
create user a identified by 123; grant dba to a;
(2)创建用户b,并创建test表,插入数据
create user b identified by 123; grant resource,connect to b; conn b/123 create table test(id number,name varchar2(10)); insert into test values(1,'xxx01'); insert into test values(2,'xxx02'); commit; select * from b.test;
(3)在a用户下创建包含访问b.test表的视图,报错
09:06:06 B@mesorcl>conn a/123 Connected. 09:06:12 A@mesorcl>create view v_b as select * from b.test; create view v_b as select * from b.test * ERROR at line 1: ORA-01031: insufficient privileges
2、问题分析
虽然a是dba,但是需要满足两个条件
(1)GRANT CREATE VIEW TO A; (2)grant select B.表 to A;
3、解决
conn b/123 grant select on b.test to a; conn a/123 create view v_b as select * from b.test;