在修改源 SQL 时,oracle 视图失去所有授权是否正常?如果这与它有任何关系,我正在使用 SQL Developer。
问问题
4784 次
1 回答
7
首先,你没有“grants”——“grant”是一个操作。你有“角色”和“特权”。
其次,视图本身既没有角色也没有特权——模式确实有。基本上,一个自我描述的命令是:grant select on view_1 to schema_1
.
第三,如果您创建或替换视图,模式不会失去其特权。这是一个快速示例:
11:03:07 @> conn system/sys@oars_sandbox
Connected.
11:03:15 SYSTEM@oars_sandbox> create user test1 identified by test1;
User created.
11:03:39 SYSTEM@oars_sandbox> create user test2 identified by test2;
User created.
11:03:48 SYSTEM@oars_sandbox> create view test1.view1 as select * from dual;
View created.
11:04:03 SYSTEM@oars_sandbox> grant select on test1.view1 to test2;
Grant succeeded.
11:04:15 SYSTEM@oars_sandbox> select grantee, owner, table_name, privilege, grantor from dba_tab_privs where grantee = 'TEST2';
GRANTEE OWNER TABLE_NAME PRIVILEGE GRANTOR
------------------------------ ------------------------------ ------------------------------ ---------------------------------------- ------------------------------
TEST2 TEST1 VIEW1 SELECT TEST1
11:05:13 SYSTEM@oars_sandbox> create or replace view test1.view1 as select * from dual;
View created.
11:05:24 SYSTEM@oars_sandbox> select grantee, owner, table_name, privilege, grantor from dba_tab_privs where grantee = 'TEST2';
GRANTEE OWNER TABLE_NAME PRIVILEGE GRANTOR
------------------------------ ------------------------------ ------------------------------ ---------------------------------------- ------------------------------
TEST2 TEST1 VIEW1 SELECT TEST1
但是,很可能 SQL 开发人员drop view
首先调用而不是create or replace
. 在这种情况下,您的权限将被自动删除。
11:05:26 SYSTEM@oars_sandbox> drop view test1.view1;
View dropped.
11:10:21 SYSTEM@oars_sandbox> select grantee, owner, table_name, privilege, grantor from dba_tab_privs where grantee = 'TEST2';
no rows selected
11:10:24 SYSTEM@oars_sandbox> create or replace view test1.view1 as select * from dual;
View created.
11:10:26 SYSTEM@oars_sandbox> select grantee, owner, table_name, privilege, grantor from dba_tab_privs where grantee = 'TEST2';
no rows selected
于 2012-10-30T03:12:52.360 回答