Sameer, your solution is not realy a sollution. Couple of remarks:
1.
You can't realy grant any privilege on a synonym. Synonyms don't have any method or functionalyty that can be granted. What you actualy executed with your "GRANT SELECT ON samv TO scott" is "GRANT SELECT ON myuser.sam TO scott". Sysnonym is not an object that something can be granted on, it is only an object through which something can be granted on another object.Originally posted by SameerCode:SQL> create view sam as select * from helloworld where name like 'P%'; View created. SQL> create synonym samv for sam; Synonym created. SQL> grant select on samv to scott; Grant succeeded.
2.
Scott can get the same output by not using that synonym, he can query the view SAM directly:Originally posted by SameerCode:SQL> select * from myuser.samv where rownum = 1; NAME ------------------------------ Production
3.Code:SQL> select * from myuser.sam where rownum = 1; NAME ---------- Production
But this does not mean that you have hidden the code of the view MYUSER.SAM from scott! Check this:Originally posted by SameerCode:SQL> select * from all_views where view_name = 'SAMV'; Es wurden keine Zeilen ausgewählt
Vhat you realy need to do if you want SCOTT to be able to query the view SAM, yet he will not be able to view the code of the view SAM is the following:Code:SQL> connect scott/tiger Connected. SQL> select * from all_views where view_name = 'SAMV'; no rows selected SQL> select view_name, text from all_views where view_name = 'SAM'; VIEW_NAME ------------------------------ TEXT -------------------------------------------------- SAM select "NAME" from helloworld where name like 'P%'
- create another view SAMV that simply selects form SAM
- grant select on SAMV to scott
- (optionaly) create a synonym SAM through which scott will reference the view SAMV, though he will essentialy get the results from view SAM.
So now SCOTT has the access to the contents of view SAM, yet he is not able to see the business logic incorporated in that view....Code:SQL> connect myuser/myuser Connected. SQL> select text from user_views where view_name = 'SAM'; TEXT ----------------------------------------------------------- select "NAME" from helloworld where name like 'P%' SQL> create view samv as select * from sam; View created. SQL> select * from sam; NAME ---------- Production SQL> grant select on samv to scott; Grant succeeded. SQL> create synonym scott.sam for myuser.samv; Synonym created. SQL> connect scott/tiger Connected. SQL> select * from sam; NAME ---------- Production SQL> select view_name, text from all_views where view_name like 'SAM%'; VIEW_NAME ------------------------------ TEXT ---------------------------------------- SAMV select "NAME" from sam




Reply With Quote