Skip to content

Instantly share code, notes, and snippets.

@nounderline
Last active January 4, 2016 12:49
Show Gist options
  • Save nounderline/8623848 to your computer and use it in GitHub Desktop.
Save nounderline/8623848 to your computer and use it in GitHub Desktop.
[Postgres] Manage roles
----------------------------------
-- Managing roles in PostgreSQL --
----------------------------------
-- Create --
CREATE ROLE name WITH PASSWORD 'd94jsfsd' LOGIN;
-- Grant privileges to database --
GRANT ALL PRIVILEGES ON DATABASE database_name TO name;
-- Grant privileges to table --
GRANT ALL PRIVILEGES ON TABLE users TO name;
-- Revoke privileges --
DROP OWNED BY name;
-- Modify --
ALTER ROLE name WITH login;
-- Delete --
DROP ROLE name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment