假設scott User想要建立一個view去select HR user的employees 某些欄位。

因為不只這個table要做成view,所以以Role的方式去設定權限給scott 。

CREATE ROLE role1;  
GRANT SELECT ON hr.employee to role1;
GRANT role1 to scott;

 

建立view卻出現"ORA-01031: insufficient privileges"錯誤訊息,無法建立view

CREATE OR REPLACE VIEW V1 AS 
SELECT last_name, salary 
FROM hr.employees;


1.我單獨下select last_name, salary from hr.employees; 是正常的,

2.若是create view內是select scott 的table,是可以的。


很怪異的情況。

 

後來發現create view 或是create procedure 內若需要使用別的schema Table,不能用role的方式給予權限,需要直接賦予權限。

GRANT SELECT ON HR.employee TO scott;

 

直接給予權限後,create view跟select view就都可以正常了。

參考網站:

http://space.itpub.net/9252210/viewspace-591741

http://kamranagayev.com/2010/06/11/getting-ora-01031-being-granted-dba-role/

arrow
arrow

    味味A 發表在 痞客邦 留言(0) 人氣()