'Check the perm 'Create Database' in PostgreSQL as well as in SQL Server
I would like to check the perm in PostgreSQL db as well as I do it via this command
'SELECT HAS_PERMS_BY_NAME(NULL, 'DATABASE', 'CREATE DATABASE')
' for the SQL server.
What is the best way to do the same in PostgreSQL? I didn`t find the similar function in PostgreSQL.
Solution 1:[1]
The privilege to create a new database is stored in pg_roles
To check if a specific user can create a new database:
select rolcreatedb
from pg_catalog.pg_roles
where rolname = current_user; --<< or replace with a specific user name
If you want to see all roles that are allowed to create a new database
select rolname
from pg_catalog.pg_roles
where rolcreatedb;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |