Getting User Information

Use the CURRENT_USER function to identify the active user within the database server.

To get the current user:

Listing 5.27. Print the current user. See Figure 5.27 for the result.
SELECT CURRENT_USER AS "User";
Figure 5.27. Result of Listing 5.27.
User
-------
cfehily

✓ Tips

  • You can use user functions in SELECT, WHERE, and ORDER BY clauses or anywhere an expression is allowed.

  • SQL also defines the SESSION_USER and SYSTEM_USER functions. The current user indicates the authorization identifier under whose privileges SQL statements currently are run. (The current user may have permission to run, say, only SELECT statements.) The session user indicates the authorization ...

Get SQL: Visual QuickStart Guide 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.