I showed users(roles) with dg
and du
, then there were the same results as shown below:
postgres=# dg
List of roles
Role name | Attributes
-----------+------------------------------------------------------------
anna |
john |
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS
postgres=# du
List of roles
Role name | Attributes
-----------+------------------------------------------------------------
anna |
john |
postgres | Superuser, Create role, Create DB, Replication, Bypass RLS
I also read the explanations of dg
and du
which are the same as shown below:
postgres=# ?
...
Informational
...
dg[S+] [PATTERN] list roles
...
du[S+] [PATTERN] list roles
...
My questions:
- What is the difference between
dg
anddu
? - If
dg
anddu
are the same, is one of them deprecated at the moment or in the future?
3
Answers
Using
psql --echo-hidden
:You can see
dg
anddu
are exactly the same thing:Neither is deprecated. It’s not guaranteed that they won’t be replaced or deprecated in the future, but it’s generally unlikely.
dg
lists groups,du
lists users, which both becameroles
in version 8.1.The documentation says:
It does not matter which one you use. I cannot see into the future, but I would be surprised if either of these commands ever gets removed. The maintenance costs are low, and backward compatibility is valued in PostgreSQL.
These commands pre-date PostgreSQL/8.1, when users and groups were replaced with a single entity, roles:
(Source)
There’s also a note in documentation for
dg
says: