O'Reilly logo

SQL: Visual QuickStart Guide by Chris Fehily

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required