ORA-01727 view賦權with grant option
ORA-01720: grant option does not exist for 'SCOTT.LOCK1'
該問題出現在將view賦權給另外的使用者時,而該view中引用了第三個使用者下的表。
例如:
我有三個使用者:scott,roy,test
在roy下建立一個view引用到scott的表
然後將roy下的view的存取權限給test
如果按普通的賦權模式,此時就會報出ORA-01720錯誤。
解決方案是:
在將表scott下的表存取權限賦權給roy使用者時,加上with grant option。
這樣當view賦權給test時就會自動把scott表的許可權給test,這樣就不會出錯了。
實驗測試:
環境本地linux RedHat 5, Oracle 11gR2
1.用dba使用者登入,先試著建立視圖roy.new_view,報錯
SQL> connect dbmgr/dbmgr;
Connected.
SQL> create view roy.new_view(id,comm) as select id,comm from scott.lock1;
create view roy.new_view(id,comm) as select id,comm from scott.lock1
*
ERROR at line 1:
ORA-00942: table or view does not exist
2.給roy賦普通許可權後,建立視圖成功
SQL> grant select on scott.lock1 to roy;
Grant succeeded.
SQL> create view roy.new_view(id,comm) as select id,comm from scott.lock1;
View created.
3.將視圖賦權給test使用者,報錯ORA-01720
SQL> grant select on roy.new_view to test;
grant select on roy.new_view to test
*
ERROR at line 1:
ORA-01720: grant option does not exist for 'SCOTT.LOCK1'
4.給roy賦權時加上with grant option 選項再將視圖賦權給test使用者,成功
SQL> grant select on scott.lock1 to roy with grant option;
Grant succeeded.
SQL> grant select on roy.new_view to test;
Grant succeeded.