Search code examples
postgresqlprivilegessql-grant

Transfer rights from user to another user


I have 3 tasks:

  1. Create a database owner with 'sa' rights.
  2. Create three database users.
  3. Transfer the rights from the user from task 1 to one of the users from task 2.

I know how to solve first and second tasks:

CREATE USER admin WITH LOGIN PASSWORD 'password' SUPERUSER;
CREATE USER user1 WITH LOGIN PASSWORD 'user1';
CREATE USER user2 WITH LOGIN PASSWORD 'user2';
CREATE USER user3 WITH LOGIN PASSWORD 'user3';

How can I solve third task?


Solution

  • You need to use the grant function:

    GRANT admin TO user1;