Created
January 10, 2018 12:17
-
-
Save rflpazini/7392011e77c7f0313a309fed0c2d8961 to your computer and use it in GitHub Desktop.
This file contains 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 a group to grant select permission | |
CREATE ROLE readaccess; | |
-- Grant access to existing tables | |
GRANT USAGE ON SCHEMA public TO readaccess; | |
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess; | |
-- Grant access to future tables | |
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess; | |
-- Create a new user with password and add this to readaccess group | |
CREATE USER myuser WITH PASSWORD 'secret'; | |
GRANT readaccess TO myuser; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment