Skip to content

Instantly share code, notes, and snippets.

@brycemcd
Last active August 27, 2018 14:58
Show Gist options
  • Save brycemcd/5558296 to your computer and use it in GitHub Desktop.
Save brycemcd/5558296 to your computer and use it in GitHub Desktop.
Postgres Role based permissions
-- create user:
CREATE COLE user_name LOGIN PASSWORD 'password' SUPERUSER;
-- create role:
CREATE ROLE overlord;
-- grant role to user:
GRANT overlord TO user_name;
-- Not very many privs
GRANT SELECT ON ALL TABLES IN SCHEMA zz_test1 TO test2;
GRANT SELECT ON ALL SEQUENCES IN SCHEMA zz_test1 TO test2;
GRANT USAGE ON SCHEMA zz_test1 TO test2;
-- muchos privs
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA zz_test1 TO test1;
GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA zz_test1 TO test1;
GRANT ALL ON SCHEMA zz_test1 TO test1;
@peycho
Copy link

peycho commented Aug 27, 2018

CREATE ROLE

not

CREATE COLE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment