Created
December 26, 2017 08:47
-
-
Save niteshy/2655b547e7f778fbb3854365276c632a 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
-- | |
-- To create the group | |
-- | |
-- Create a ro_group (readonly group) | |
CREATE ROLE ro_group; | |
-- Grant access to existing tables | |
GRANT USAGE ON SCHEMA public TO ro_group; | |
GRANT SELECT ON ALL TABLES IN SCHEMA public TO ro_group; | |
-- Grant access to future tables | |
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO ro_group; | |
-- Create a ro_user (readonly user) with password ('secret') | |
CREATE USER ro_user WITH PASSWORD 'secret'; | |
GRANT ro_group TO ro_user; | |
-- | |
-- To remove the group | |
-- | |
-- REVOKE ro_group | |
REVOKE USAGE ON SCHEMA public FROM ro_group; | |
-- REVOKE ro_group | |
REVOKE ALL ON public FROM ro_group; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment