I have DB \"test\" in PostgreSql. I want to write sql to get owner my database.
You can use the combination of pg_database, pg_users system tables and current_database() function in this way:
pg_database
pg_users
current_database()
SELECT u.usename FROM pg_database d JOIN pg_user u ON (d.datdba = u.usesysid) WHERE d.datname = (SELECT current_database());