Last active
December 10, 2015 04:08
-
-
Save reterVision/4379026 to your computer and use it in GitHub Desktop.
How to create a role and grant a view to him with the read only privilege in postgres.
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 <newuser> WITH LOGIN ENCRYPTED PASSWORD <password>; | |
CREATE VIEW <viewname> AS SELECT * FROM <yourtable> LIMIT 20; | |
GRANT CONNECT ON DATABASE "<databasename>" TO <newuser>; | |
GRANT SELECT ON schemaname.viewname TO <newuser>; | |
REVOKE ALL PRIVILEGES ON <schemaname> FROM <newuser>; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment