简体   繁体   English

如何从数据库中获取登录用户的名称?

[英]How can I get the name of a logged in user from a database?

More specifically an Oracle database.更具体地说,是 Oracle 数据库。 Say I am logged in as foo .假设我以foo身份登录。 How do I get the name?我如何得到这个名字?

Also does this pose a security risk if the name is exposed to someone?如果名称暴露给某人,这是否也会带来安全风险?

SELECT user, uid FROM dual

From http://sqlzoo.net/howto/source/z.dir/tip492545/oracle来自http://sqlzoo.net/howto/source/z.dir/tip492545/oracle

(First google hit on "oracle whoami") (第一个谷歌点击“oracle whoami”)

in sqlplus you can just type在 sqlplus 你可以输入

show user

Another option:另外的选择:

SELECT * from user_users

I'd personally probably use the USER function (as stated by Stefan in one of the other answers) by using select user from dual or something similar but it's good to have other options.我个人可能会通过使用select user from dual使用USER function (如 Stefan 在其他答案之一中所述),但最好有其他选项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用两个不同的数据库表获取当时登录用户的描述? - how can i get the description of the user who is logged in at that moment using two different database table? 如何从用户表中获取投票者的姓名? - How can I get the name of voter from the user's table? 如何让用户使用 SQLite 保持登录状态? - How can I keep a user logged in with SQLite? ASP.NET如何从SQL数据库获取当前登录的用户名和ID - ASP.NET how to get the currently logged in users name and ID from a SQL database 我可以获取调用存储过程的数据库的ID /名称吗? - Can I get the ID/name of database that a stored procedure is called from? 我可以从Wordpress数据库中获取React应用程序的用户密码吗? - Can I get user password from Wordpress database for React application? PHP / SQL-如何获取数据库中表的名称? - PHP/SQL - How can I get the name of tables in my database? 如何获得每个用户的ID? - How can I get the name of each user by his id? 我如何从数据库中获取行 - How can i get rows from database 我如何从 mysql sakila 数据库中获得以下结果集:所有电影的列表以及该电影中每个演员的名字和名字 - How can I get the following result set from mysql sakila database: List of all the films with film name and name of every actor in that film
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM