Creating a user (also known as a role) in PostgreSQL and assigning a database to…