Created
August 16, 2013 22:19
-
-
Save joshbode/6253980 to your computer and use it in GitHub Desktop.
Grant access to multiple people working on a project to tables with names matching a particular pattern.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- grant access to multiple people | |
| DECLARE | |
| usernames VARCHAR2(1024) := ' | |
| jimmy, | |
| bobby, | |
| franky, | |
| alice, | |
| mandy | |
| '; | |
| table_filter VARCHAR2(128) := 'foo|bar'; | |
| BEGIN | |
| FOR r IN ( | |
| SELECT LOWER(t.table_name) table_name | |
| FROM user_tables t | |
| WHERE REGEXP_LIKE(t.table_name, '^(' || table_filter || '_)') | |
| ) LOOP | |
| EXECUTE IMMEDIATE 'GRANT SELECT ON ' || r.table_name || ' TO ' || usernames; | |
| END LOOP; | |
| END; | |
| / |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment