Created
January 22, 2018 20:05
-
-
Save arthuralvim/05602501509991702ca7ce87a47a5e2d to your computer and use it in GitHub Desktop.
Working with permissions on PostgreSQL.
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 ROLE [user_read_only] WITH LOGIN PASSWORD 'mysuperstrongpassword' NOSUPERUSER INHERIT NOCREATEDB NOCREATEROLE NOREPLICATION VALID UNTIL 'infinity'; | |
GRANT CONNECT ON DATABASE [database_name] TO [user_read_only]; | |
GRANT USAGE ON SCHEMA public TO [user_read_only]; | |
GRANT SELECT ON [table_name] TO [user_read_only]; | |
REVOKE ALL ON DATABASE [database_name] FROM [user_read_only]; | |
REVOKE ALL ON SCHEMA public FROM [user_read_only]; | |
REVOKE ALL ON [table_name] FROM [user_read_only]; | |
DROP USER [user_read_only]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment