视图在修改时丢失其授权

时间:2012-10-30 00:25:26

标签: sql oracle view

在修改源SQL时,oracle视图是否正常删除所有授权? 我正在使用SQL Developer,如果它与它有任何关系。

1 个答案:

答案 0 :(得分:6)

首先,你没有"拨款" - " grant"是一项行动。你有"角色"和#34;特权"。

其次,视图本身既没有角色也没有特权 - 模式确实有。基本上,自我描述性命令是: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