Take the 2-minute tour ×
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. It's 100% free, no registration required.

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
add comment

2 Answers 2

up vote 7 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
    
That's it. Thanks. –  pedrosanta Aug 18 '11 at 16:22
add comment

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
add comment

Your Answer

 
discard

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.