Get DB owner's name in PostgreSql

后端 未结 7 2169
忘了有多久
忘了有多久 2020-12-15 02:07

I have DB \"test\" in PostgreSql. I want to write sql to get owner my database.

7条回答
  •  孤城傲影
    2020-12-15 02:50

    You can use the combination of pg_database, pg_users system tables and current_database() function in this way:

     SELECT u.usename 
     FROM pg_database d
      JOIN pg_user u ON (d.datdba = u.usesysid)
     WHERE d.datname = (SELECT current_database());
    

提交回复
热议问题