Thursday, February 23, 2017

Grant SELECT on all tables in Oracle/PLSQL

Execute the anonymous block below:

DECLARE
  STMT VARCHAR2(100);
BEGIN
FOR x IN (SELECT TABLE_NAME FROM user_tables)
LOOP
  STMT := 'GRANT SELECT ON ' || x.TABLE_NAME || ' TO <user>';
  EXECUTE IMMEDIATE STMT;
END LOOP;
END;

No comments:

Post a Comment