daily pastebin goal
64%
SHARE
TWEET

Untitled

a guest Mar 19th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- Create a group with read-only access
  2. CREATE ROLE readonly;
  3.  
  4. -- Grant access on public sheme to existing tables
  5. GRANT USAGE ON SCHEMA public TO readonly;
  6. ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readonly; -- grant access to future tables
  7.  
  8. -- Grant access to specific database, repeat code below for each database
  9. GRANT CONNECT ON DATABASE db_name to readonly;
  10. ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT ALL ON TABLES TO readonly; -- grant access to future tables
  11. GRANT USAGE ON SCHEMA public to readonly;
  12. GRANT SELECT ON ALL SEQUENCES IN SCHEMA public TO readonly;
  13. GRANT SELECT ON ALL TABLES IN SCHEMA public TO readonly;
  14.  
  15. -- Create a user with password
  16. CREATE USER ro_user WITH ENCRYPTED PASSWORD 'ro_password';
  17. GRANT readaccess TO ro_user;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top