Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm in the middle of a database server migration and I can't figure (after googling and searching here) how can I list the database privileges (or all the privileges across the server) on PostgreSQL using the psql command line tool?

I'm on Ubuntu 11.04 and my PostgreSQL version is 8.2.x.

share|improve this question
up vote 33 down vote accepted
postgres=> \l
                                   Liste der Datenbanken
      Name      | Eigentümer | Kodierung | Sortierfolge | Zeichentyp |  Zugriffsprivilegien  
postgres       | postgres   | UTF8      | de_AT.utf8   | de_AT.utf8 | 
template0      | postgres   | UTF8      | de_AT.utf8   | de_AT.utf8 | =c/postgres
                                                                      : postgres=CTc/postgres
template1      | postgres   | UTF8      | de_AT.utf8   | de_AT.utf8 | =c/postgres
                                                                      : postgres=CTc/postgres

The docs give an explanation of how to interpret this output. For specific privilages an a table of the current DB, use \z YOURTABLE

share|improve this answer

perhaps you mean listing users and their privileges for a database - I can't quite tell from the question:

postgres=> \du
                             List of roles
    Role name    |  Attributes  |                    Member of
 dba             | Create role  | {util_user,helpdesk_user,helpdesk_admin}
 helpdesk_admin  | Cannot login | {helpdesk_user}
 helpdesk_user   | Cannot login | {helpdesk_reader}
 jack            |              | {helpdesk_admin}
 postgres        | Superuser    | {}
                 : Create role
                 : Create DB
share|improve this answer
Nope I wanted a way to list the privileges of a specific database, but I already figured it out. Owner of the database always has all privileges, right? And afterwards we can add more privileges on the database to other users/groups. Those are listed with the \l command. But very thanks anyway. – pedrosanta Aug 18 '11 at 16:20

A (possibly obvious) additional step is become the postgres user, otherwise you may get errors about roles not existing.

sudo su - postgres
psql -l


postgres=> \l
share|improve this answer
Meta: I'm adding this because this question is highly rated on the google query "postgres list roles" and I spent a bit of time in much lower ranked results before I found what I wanted, so I'm memorializing the extra info. – Adam Shostack Dec 18 '15 at 19:04

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.