Cloud

pg_get_userbyid

The pg_get_userbyid() is a system catalog information function that retrieves the name of a user (role) given its unique identifier (OID).

Syntax

pg_get_userbyid(role_oid)

Parameters

  • role_oid: Specifies the object identifier (OID) of the user.

Examples

Get the OIDs of all the users:

SELECT id,name FROM oxla_internal.oxla_role;

The query returns the list of users with their IDs (OIDs):

 id |  name
----+---------
  1 | oxla
  2 | other_user
(2 rows)

Translate the OID to a role name:

SELECT pg_get_userbyid(2);

The query returns:

 pg_get_userbyid
-----------------
 other_user
(1 row)