注意with grant option!!!
整试验个过程如下:
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行。