Re: Role and grants - Mailing list pgsql-general

From Melvin Davidson
Subject Re: Role and grants
Date
Msg-id CANu8FixwH-BrcrFPzg6dmpxXXf8Lh2GH7A70iBqAv5F+zHfAdA@mail.gmail.com
Whole thread Raw
In response to Role and grants  ("Fran ..." <Bryan691@hotmail.com>)
List pgsql-general


On Wed, Nov 9, 2016 at 2:05 PM, Fran ... <Bryan691@hotmail.com> wrote:

Hi,


I am a new user with PostgreSQL, I came from MySQL and I am experiencing some issues with roles and privileges.


I have created a DB,user and grant privilege on this DB to this user. How could I check what is the privileges/permissions for this user?


Transcript:


postgres=# create database test;
CREATE DATABASE
postgres=# create user test with password 'test';
CREATE ROLE
postgres=# grant all privileges on database test to test;
GRANT
postgres=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 test      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/postgres         +
           |          |          |             |             | postgres=CTc/postgres+
           |          |          |             |             | test=CTc/postgres
 test1     | test1    | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =Tc/test1            +
           |          |          |             |             | test1=CTc/test1
(5 rows)

With "\l" command It's no clear.


Finally, I don't find some command like "show grants for..." in MySQL.


Regards.

Bryan


You can use the following query to show what table <USERNAME>  can access.
Just replace <USERNAME> with the actual username you want.

SELECT *
  FROM information_schema.table_privileges
 WHERE grantee = '<USERNAME>'
ORDER BY table_schema,table_name, privilege_type;

--
Melvin Davidson
I reserve the right to fantasize.  Whether or not you
wish to share my fantasy is entirely up to you.

pgsql-general by date:

Previous
From: "Fran ..."
Date:
Subject: Role and grants
Next
From: Adrian Klaver
Date:
Subject: Re: Role and grants