A
A
AlmazKayum2018-02-05 10:53:27
PostgreSQL
AlmazKayum, 2018-02-05 10:53:27

What is ROLES in PostgreSQL?

quote from https://www.digitalocean.com/community/tutorials/p...

Another assumption that Postgres makes is that for each role that has been used to login, it must create a database with the same name as the name of the role that can be accessed by that role.
Therefore, for the user we created earlier called sammy, the corresponding role will by default try to connect to the sammy database. You can create this database using the createdb command.

i.e. one role for one database? why?
whether it is possible so: some roles and one database?
please explain the meaning of roles in postgres

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Melkij, 2018-02-05
@AlmazKayum

please explain the meaning of roles in postgres

A user is an alias for the role system.
It's a lie. There is no need.
And this is true. But only if the connection base name is not overridden, for example, by the PGDATABASE environment variable . And of course, you can simply set it as a connection argument.
Of course. Though a tree with multiple inheritance of roles.
Only important point - the roles are global within the cluster. You can't make a user in the foo database with one password and a user in the bar database with a different password. But to give readonly to one database and full rights to another - that's welcome.

M
Maxim Fedorov, 2018-02-05
@Maksclub

Several useful sections about roles:
https://postgrespro.ru/docs/postgresql/9.4/user-ma...

A
Alexander Shelemetiev, 2018-02-05
@zoroda

If the databases are located on the same PostgreSQL instance , then they share the same roles. It doesn't make much sense to create separate roles for each of these databases.
You can create multiple roles in the same database. This is fine. For example, the roles of admin and regular user.
A role is a concept that combines users and user groups. That is, both users and their groups are essentially roles in PostgreSQL. Each of the roles can be assigned some access rights.
Documentation about roles

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question