From: | Muhammad Usman Khan <usman(dot)k(at)bitnine(dot)net> |
---|---|
To: | somnath som <som(dot)somnath16(at)gmail(dot)com> |
Cc: | Pgsql-admin <pgsql-admin(at)lists(dot)postgresql(dot)org> |
Subject: | Re: User Privileges Issue |
Date: | 2024-08-30 11:44:57 |
Message-ID: | CAPnRvGv4fzFYwpoObd5k=4RZYEJuys7DKaHiwXGXS8UMJuKmtg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-admin |
Hi,
You can use the following queries to check privileges. I have tested with
my created user 'user01'
*Check Role Attributes *
postgres=# SELECT rolname, rolsuper, rolinherit, rolcreaterole,
rolcreatedb, rolcanlogin, rolreplication
postgres-# FROM pg_roles
postgres-# WHERE rolname = 'user01';
rolname | rolsuper | rolinherit | rolcreaterole | rolcreatedb |
rolcanlogin | rolreplication
---------+----------+------------+---------------+-------------+-------------+----------------
user01 | f | t | f | f | t
| f
(1 row)
*Check Database Privileges:*
postgres=# SELECT datname,
postgres-# has_database_privilege('user01', datname, 'CONNECT') AS
connect,
postgres-# has_database_privilege('user01', datname, 'CREATE') AS
create,
postgres-# has_database_privilege('user01', datname, 'TEMP') AS temp
postgres-# FROM pg_database;
datname | connect | create | temp
-----------+---------+--------+------
postgres | t | f | t
agens | t | f | t
template1 | t | f | f
template0 | t | f | f
(4 rows)
*Check Schema Privileges:*
postgres=# SELECT nspname,
postgres-# has_schema_privilege('user01', nspname, 'CREATE') AS
create,
postgres-# has_schema_privilege('user01', nspname, 'USAGE') AS usage
postgres-# FROM pg_namespace;
nspname | create | usage
--------------------+--------+-------
pg_toast | f | f
pg_temp_1 | f | f
pg_toast_temp_1 | f | f
pg_catalog | f | t
public | t | t
information_schema | f | t
(6 rows)
On Fri, 30 Aug 2024 at 16:38, somnath som <som(dot)somnath16(at)gmail(dot)com> wrote:
> We have one user like “Test_User”, Can I check what all previliges are
> there for “Test_User”.
>
> When running \du+ command then only can see for superuser, others user are
> not showing.
>
> Please provide me command to check what all previliges are there for a
> user.
>
From | Date | Subject | |
---|---|---|---|
Next Message | Rajesh Kumar | 2024-08-30 11:49:46 | DR set up. |
Previous Message | Kashif Zeeshan | 2024-08-30 11:43:36 | Re: User Privileges Issue |