Skip to content

Instantly share code, notes, and snippets.

@secilreel
Created February 25, 2019 16:55
Show Gist options
  • Save secilreel/f4d6fcd6b0833c80535a685ba4968679 to your computer and use it in GitHub Desktop.
Save secilreel/f4d6fcd6b0833c80535a685ba4968679 to your computer and use it in GitHub Desktop.
The receptionists at Dunder Mifflin would like to create and manage their own database of visitors to the office. Create two roles, erin and erin_admin. Make the erin_admin role a superuser. Create a database named visitors with erin_admin as the owner.
psql postgres
postgres=# CREATE ROLE erin;
postgres=# CREATE ROLE erin_admin WITH SUPERUSER;
postgres=# CREATE DATABASE visitors;
postgres=# ALTER DATABASE visitors OWNER TO erin_admin;
postgres=# \q
psql visitors
visitors=# \du
List of roles
Role name | Attributes | Member of
------------+------------------------------------------------------------+-----------
erin | Cannot login | {}
erin_admin | Superuser, Cannot login | {}
postgres | Superuser | {}
secilreel | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment