Grant Select on all Tables Owned By Specific User

后端 未结 4 1158
春和景丽
春和景丽 2020-12-02 16:55

I need to grant select permission for all tables owned by a specific user to another user. Can I do this with a single command along the lines of:

Grant Sel         


        
4条回答
  •  抹茶落季
    2020-12-02 17:45

    Well, it's not a single statement, but it's about as close as you can get with oracle:

    BEGIN
       FOR R IN (SELECT owner, table_name FROM all_tables WHERE owner='TheOwner') LOOP
          EXECUTE IMMEDIATE 'grant select on '||R.owner||'.'||R.table_name||' to TheUser';
       END LOOP;
    END; 
    

提交回复
热议问题