CURRENT_ROLE
Example
Section titled “Example”SELECT CURRENT_ROLE;Output
Section titled “Output”myusernameExplanation
Section titled “Explanation”The CURRENT_ROLE function in PostgreSQL returns the name of the current role for the active session. In the output, myusername represents the current role name that the function returned.
Example
Section titled “Example”SELECT CURRENT_USER;Output
Section titled “Output”'username'Explanation
Section titled “Explanation”In this example, the CURRENT_USER function in SQL Server is used to return the name of the user who is currently connected to the database. The output will be the ‘username’ of the currently logged-in user.
Note: SQL Server does not have a CURRENT_ROLE function, but CURRENT_USER or USER can be used to determine the user context in which SQL Server code is running.
Example
Section titled “Example”SELECT CURRENT_ROLE FROM dual;Output
Section titled “Output”CONNECTExplanation
Section titled “Explanation”The CURRENT_ROLE is a built-in function in Oracle that returns the name of the active role for the current user session. In the example, it is used to pull the current active role from the dual table, a special one-row, one-column table present by default in all Oracle databases. The output CONNECT is the active role for the current database session.