oracle817下测试没有问题。SQL> create user temp identified by temp;用户已创建已用时间: 00: 00: 00.90
SQL> grant connect to temp;授权成功。已用时间: 00: 00: 00.30
SQL> conn scott/tiger
已连接。
SQL> create or replace view vc as
2 select deptno from emp
3 union all
4 select deptno from dept;视图已建立。已用时间: 00: 00: 00.31
SQL> grant select on vc to temp;授权成功。已用时间: 00: 00: 00.30
SQL> conn temp/temp
已连接。
SQL> desc scott.vc
名称 空? 类型
----------------------------------------- -------- --------------
DEPTNO NUMBER(2)SQL> select * from scott.vc; DEPTNO
----------
20
30
30
20
30
30
10
20
10
30
20 DEPTNO
----------
30
20
10
10
20
30
40已选择18行。已用时间: 00: 00: 00.80
SQL> select * from scott.dept;
select * from scott.dept
*
ERROR 位于第 1 行:
ORA-00942: 表或视图不存在
已用时间: 00: 00: 00.40
SQL>
SQL> grant connect to temp;授权成功。已用时间: 00: 00: 00.30
SQL> conn scott/tiger
已连接。
SQL> create or replace view vc as
2 select deptno from emp
3 union all
4 select deptno from dept;视图已建立。已用时间: 00: 00: 00.31
SQL> grant select on vc to temp;授权成功。已用时间: 00: 00: 00.30
SQL> conn temp/temp
已连接。
SQL> desc scott.vc
名称 空? 类型
----------------------------------------- -------- --------------
DEPTNO NUMBER(2)SQL> select * from scott.vc; DEPTNO
----------
20
30
30
20
30
30
10
20
10
30
20 DEPTNO
----------
30
20
10
10
20
30
40已选择18行。已用时间: 00: 00: 00.80
SQL> select * from scott.dept;
select * from scott.dept
*
ERROR 位于第 1 行:
ORA-00942: 表或视图不存在
已用时间: 00: 00: 00.40
SQL>
SQL> create user ua identified by ua;用户已创建SQL> create user ub identified by ub;用户已创建SQL> grant connect,resource to ua;授权成功。SQL> grant connect,resource to ub;授权成功。SQL> conn ua/ua@mydb
已连接。
SQL> create table ta(id integer,fa integer);表已创建。
SQL> begin
2 for x in 1..10 loop
3 insert into ta values(x,x+20);
4 end loop;
5 commit;
6 end;
7 /PL/SQL 过程已成功完成。SQL> select * from ta; ID FA
---------- ----------
1 21
2 22
3 23
4 24
5 25
6 26
7 27
8 28
9 29
10 30已选择10行。SQL> create table tb(id integer,fb integer);表已创建。SQL> begin
2 for x in 1..10 loop
3 insert into tb values(x,x+60);
4 end loop;
5 commit;
6 end;
7 /PL/SQL 过程已成功完成。SQL> select * from tb; ID FB
---------- ----------
1 61
2 62
3 63
4 64
5 65
6 66
7 67
8 68
9 69
10 70已选择10行。
SQL> create view vc as
2 select ta.id,fa,fb from ta,tb
3 where ta.id=tb.id;视图已建立。SQL> select * from vc; ID FA FB
---------- ---------- ----------
1 21 61
2 22 62
3 23 63
4 24 64
5 25 65
6 26 66
7 27 67
8 28 68
9 29 69
10 30 70已选择10行。SQL> grant select on vc to ub;授权成功。SQL> conn ub/ub@mydb
已连接。
SQL> select * from ua.vc; ID FA FB
---------- ---------- ----------
1 21 61
2 22 62
3 23 63
4 24 64
5 25 65
6 26 66
7 27 67
8 28 68
9 29 69
10 30 70已选择10行。
原来TB是一个同义词来的。它属于另外一个用户UC的。完整的问题描述如下:在Oracle中建立了两个用户,
UA, UB, UC
其中UC有TB表,同时 grant select on tb to ua,
其中UA有TA表,TB同义词(synonym UC.TB的) 及 VC 视图,其中 VC视图和了 TA中的FA字段, TB中的FB字段。
现在我想将VC授权给UB,让UB可以读取
在UA下
grant select on vc to ub;
Oracle提示成功。
但当我用UB登录后再 select * from ua.vc的话,就说权限不足。
但可以用语句 desc ua.vc来显示ua.vc的结构。
请问各位大侠,这个如何授权啊?
是不是要将 FA, FB都授权给UB呢?(这样太麻烦了吧?)
还是要将 TA, TB都授权UB?(我是因为不想公开TA和TB给UB才建立VC的)
就算我grant select on ua.tb to uc 结果也是一样。
请问如何解决呢?分不够,可再加。谢谢
SQL> create user ua identified by ua;用户已创建SQL> create user ub identified by ub;用户已创建SQL> create user uc identified by uc;用户已创建SQL> grant connect,resource to ua,ub,uc;授权成功。SQL> conn ua/ua@mydb
已连接。
SQL> create table ta(id integer,fa integer);表已创建。
SQL> begin
2 for x in 1..10 loop
3 insert into ta values(x,x+20);
4 end loop;
5 commit;
6 end;
7 /PL/SQL 过程已成功完成。SQL> select * from ta; ID FA
---------- ----------
1 21
2 22
3 23
4 24
5 25
6 26
7 27
8 28
9 29
10 30已选择10行。SQL> conn uc/uc@mydb
已连接。
SQL> create table tb(id integer,fb integer);表已创建。SQL> begin
2 for x in 1..10 loop
3 insert into tb values(x,x+60);
4 end loop;
5 commit;
6 end;
7 /PL/SQL 过程已成功完成。SQL> select * from tb; ID FB
---------- ----------
1 61
2 62
3 63
4 64
5 65
6 66
7 67
8 68
9 69
10 70已选择10行。SQL> grant select on tb to ua with grant option; -- 注意此处!!!!授权成功。SQL> conn ua/ua@mydb
已连接。SQL> create synonym tb for uc.tb;同义词已创建。SQL> create or replace view vc
2 as
3 select ta.id,fa,fb
4 from ta,tb
5 where ta.id=tb.id;视图已建立。SQL> select * from tab;TNAME TABTYPE CLUSTERID
------------------------------ ------- ----------
TA TABLE
TB SYNONYM
VC VIEW已选择3行。SQL> grant select on vc to ub;授权成功。SQL> conn ub/ub@mydb
已连接。
SQL> select * from ua.vc; ID FA FB
---------- ---------- ----------
1 21 61
2 22 62
3 23 63
4 24 64
5 25 65
6 26 66
7 27 67
8 28 68
9 29 69
10 30 70已选择10行。
十分感谢!!!!
请到另外的贴中取分。
十分感谢!!!!
请到另外的贴中取分。
http://community.csdn.net/Expert/topic/4203/4203626.xml?temp=.5095636