Created
July 12, 2015 17:52
-
-
Save joepreludian/83782cf38f33c591bc12 to your computer and use it in GitHub Desktop.
Granting schema to SQL
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
| CREATE USER readonly WITH ENCRYPTED PASSWORD 'readonly'; | |
| GRANT USAGE ON SCHEMA public to readonly; | |
| ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readonly; | |
| -- repeat code below for each database: | |
| GRANT CONNECT ON DATABASE foo to readonly; | |
| \c foo | |
| GRANT USAGE ON SCHEMA public to readonly; | |
| GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO readonly; | |
| GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly; |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simple Postgres creating roles with readonly perms;