HAS_DATABASE_PRIVILEGE

Return true if the user has the specified privilege for the specified database.
HAS_DATABASE_PRIVILEGE([role,] database, privilege)

If the role name is omitted, the function returns results for the current user.

Valid privilege values are:
  • CONNECT
  • CREATE
  • TEMP
  • TEMPORARY
Note: This function cannot be used in a query that has a FROM clause (with table references).
For example:
premdb=# select has_database_privilege('bobr','premdb','create');
 has_database_privilege 
------------------------
 f
(1 row)
premdb=# select has_database_privilege('premdb','create');
 has_database_privilege 
------------------------
 t
(1 row)