Error when assigning a role to user I have created a role called "role1" with these steps :

postgres=# CREATE ROLE role1;
CREATE ROLE
postgres=# GRANT CONNECT ON DATABASE paybills TO role1;
GRANT
postgres=# \c paybills
You are now connected to database "paybills".
paybills=# GRANT SELECT, UPDATE, INSERT, DELETE ON myeg_users TO role1;
GRANT


The steps above are all successful.

However, when I run the command below :

paybills=# GRANT role1 TO surentran;
ERROR:  role "surentran" does not exist


As you can see, an error is thrown. I am in the db called "paybills", and the user details are stored in a table called "myeg_users" within this database.

How do I add all the users in the "myeg_users" table into the role "role1"?
You can only GRANT to a PostgreSQL role.  If you have created your own role system at the application level, storing the data about them in the database, PostgreSQL has no idea that you did that and certainly isn't going to grant PostgreSQL privileges to these roles.

You either need to convert the users listed in "myeg_users" into PostgreSQL users/roles, or you need your app server to connect as PostgreSQL user "role1" and then to voluntarily do only those things the app-side role it is implementing is allowed to do.