-> A role can be thought of as either a database user, or a group of database users, depending on how the role is set up.
-> Roles can own database objects (for example, tables and functions) and can assign privileges on those objects to other roles to control who has access to which objects.
-> Any role can act as a user, a group, or both.
Create Role:
Syntax:CREATE ROLE name;
Drop Role:
Syntax:Drop Role name;
-> To get the set of existing roles
cmd:SELECT rolname FROM pg_roles;
To create super user:
Syntax: Create Role postgres superuser;
Note: Create user and create role both perform the same function.
To grant all privilliges to the role:
GRANT ALL ON TABLE table_name TO postgres;
GRANT ALL ON TABLE table_name TO dev_user;
To alter the ownership of a role:
ALTER TABLE attribute OWNER TO john;
To change the serach_path of the database:
cmd: ALTER ROLE dev_user IN DATABASE test_db SET search_path = dev_schema;
or
cmd:ALTER DATABASE SET search_path TO schema1,schema2;
Note: By default the search path will be public.