Special privileges granted to demand

Scene: Table HZQ users to create their own can not have grant permissions A user needs to be able to carry out the list of authorized users of HZQ table.

CREATE OR REPLACE TRIGGER TR_TABLE_GRANT
 BEFORE GRANT ON database
 DECLARE
 v_owner varchar(30);
 v_table_name varchar(30);
 v_oper_user varchar(30);
BEGIN
    v_owner := SYS.DICTIONARY_OBJ_OWNER;
    v_table_name := SYS.DICTIONARY_OBJ_NAME;
    v_oper_user := ora_login_user;
 IF( v_owner = 'HZQ' and v_oper_user not in ('DBADMIN','A'))
  THEN
    RAISE_APPLICATION_ERROR( -20001, 
                             ' No grant privilege on '||v_owner||'.'||v_table_name||' !!!' );
  END IF;  
END;
/

The results show

自己创建的表不能授权
SQL> conn hzq/hzq
Connected.
SQL> create table t1(id int);

Table created.
SQL> grant select on hzq.t1 to b;
grant select on hzq.t1 to b
                    *
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-20001:  No grant privilege ON HZQ.T1 !!! 
ORA - 06512 : AT Line 11 
is currently only authorized users can sys 

attention dbadmin have dba privileges 
SQL > conn dbadmin / Pass 
Connected. 
SQL >  Grant  the SELECT  ON hzq.t1 to c; 

Grant succeeded.. 
even if the user sys does not grant permissions 
SQL > conn /  AS sysdba 
Connected. 
SQL >  grant  the SELECT  ON hzq.t1 to b;
 grant  the SELECT  ON hzq.t1 tob
                     * 
ERROR AT Line 1 : 
ORA - 00604 : error occurred AT recursive This SQL Level  1 
ORA - 20001 : No Grant Privilege ON HZQ.T1 !!! 
ORA - 06512 : AT Line 11 

now dbadmin be granted to a cascade hzq.t1 , a table allows the user to grant permission hzq trigger, a user can grant permissions 
SQL >  grant  the SELECT  oN hzq.t1 to c with  grant  the Option ; 

grant succeeded.. 

SQL >  grant  the SELECT on hzq.t1 to a with grant option;

Grant succeeded.
SQL> conn c/c
Connected.
SQL> grant select on hzq.t1 to dbadmin;
grant select on hzq.t1 to dbadmin
                    *
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-20001:  No grant privilege on HZQ.T1 !!!
ORA-06512: at line 11


SQL> conn a/a
Connected.
SQL> grant select on hzq.t1 to dbadmin;

Grant succeeded.

 

Guess you like

Origin www.cnblogs.com/houzhiqing/p/10975266.html