Current_User

Returns the current database username.

Synopsis

CURRENT_USER

Parameters

This function does not accept parameters.

Results

This function returns the name of the current database user.

Description

Use the CURRENT_USER function to retrieve the name of the current user in a string of type name (a 31 character length non-standard type used for storing system identifiers).

Examples

The following example displays the current user logged into testdb:

testdb=# SELECT CURRENT_USER AS myself;
 myself
--------
 jlx
(1 row)

Get Practical PostgreSQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.