POSTGRESQL-ESSENTIALS practice question 2 of 15
Which psql meta-command is used to display all roles and their attributes?
Full set: 71 questionsThe \du meta-command in psql is used to list all available roles. Since PostgreSQL version 8.1, the concepts of "users" and "groups" have been unified into a single entity type called a "role". Therefore, \du displays all roles, which encompasses what were formerly known as users and groups. The output includes the role name and a list of its attributes, such as Superuser, Create role, Create DB, Connections, and membership in other roles. The \du command is an alias for \dg, providing identical functionality.
\dr: This is not a valid psql meta-command for listing roles. The \drds command exists to show default access privileges, but \dr is not a defined command. \roles: This is not a valid psql meta-command. Meta-commands must begin with a backslash (\). ROLES is a SQL identifier, not a client command. \users: This is not a valid psql meta-command. Like \roles, it lacks the required backslash prefix and is not a defined psql command.
1. PostgreSQL 16 Documentation, psql Meta-Commands: The official documentation lists \du and its alias \dg as the commands to "list roles". The table explicitly describes its function.
Source: PostgreSQL 16 Documentation, Section: psql, Subsection: "Meta-Commands". The table under the "Informational" category lists \du[S+] [pattern] with the description "list roles".
2. PostgreSQL 16 Documentation, Database Roles: This section clarifies the unification of users and groups into roles, which is fundamental to understanding why \du lists all of them.
Source: PostgreSQL 16 Documentation, Chapter 22: "Database Roles", Section 22.1: "Database Roles". The first paragraph states, "PostgreSQL manages database access permissions using the concept of roles. A role can be thought of as either a database user, or a group of database users... Since version 8.1, users and groups are unified into a single kind of entity called a role."
Keep practicing
Take the free POSTGRESQL-ESSENTIALS practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other POSTGRESQL-ESSENTIALS practice questions
- Question 1What is the purpose of the autovacuum parameter in PostgreSQL?
- Question 3SERIAL and IDENTITY columns can be used to add an auto-incrementing column in a Postgres …
- Question 4You are connected to a PostgreSQL database. After executing a complex query an error mess…
- Question 5Which PostgreSQL configuration parameter controls the amount of memory used for sorting o…
- Question 6You want to set the maximum time to complete client authentication to 10 seconds. Which p…
- Question 7You need to configure your server to accept TCP/IP connections from specific IP addresses…
