I have DB \"test\" in PostgreSql. I want to write sql to get owner my database.
This work with database owned by group role:
SELECT
U.rolname
,D.datname
FROM
pg_roles AS U JOIN pg_database AS D ON (D.datdba = U.oid)
WHERE
D.datname = current_database();
Using pg_authid (as I did in my previous version) instead of pg_roles is limited to SuperUser because it holds password (see documentation):
Since this catalog contains passwords, it must not be publicly readable.
pg_rolesis a publicly readable view onpg_authidthat blanks out the password field.