Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PLSQL, SQL*PLUS get current username?

Tags:

sql

plsql

sqlplus

I know that the show user command return: USER is "SCOTT"

But is it possible in a sql query or in a plsql script to only get the username of the current user and store it in a variable?

like image 520
user2420374 Avatar asked May 01 '14 22:05

user2420374


2 Answers

The USER built-in function may be used.

DECLARE
  v VARCHAR2(30);
BEGIN
  v := USER;
END;
like image 192
Jeffrey Kemp Avatar answered Sep 23 '22 09:09

Jeffrey Kemp


SYS_CONTEXT( 'USERENV', 'CURRENT_USER' )
like image 27
Chains Avatar answered Sep 24 '22 09:09

Chains