How can I easily grant permissions on all tables in another Oracle schema

Sometimes youneed to grant some permissions, for instance SELECT,  on all tables in another schema.

Espacially when you use Privacy  and the user for this is not the same as the tables to anonimize.

Of course this is something for a DBA, but sometimes you need to do this yourself.

Step-by-step guide

  1. Login a Sql Query tool like "SQL Developer"  with SYS permissions
  2. Assume: 
    PRVUSER = the schema Privacy is using
    OTHERUSER = the other schema user .

  3. Execute this script:
    BEGIN
    FOR i IN (SELECT table_name FROM DBA_TABLES WHERE OWNER = 'OTHERUSER')
    LOOP
      EXECUTE IMMEDIATE ('grant select on "OTHERUSER".'|| i.table_name ||' to "PRVUSER"');
    END LOOP;
    END;