oracle 如何显示数据库的特定用户

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13706817/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:18:21  来源:igfitidea点击:

how can i display the specific users of a database

oracleoracle10gsqlplus

提问by droidlulz

How can I display specific usernames of a database on oracle 10g using the sql*plus on console? I have been looking for a link column on the following tables v$database, all_users, dba_users, v$session.

如何在控制台上使用 sql*plus 在 oracle 10g 上显示数据库的特定用户名?我一直在寻找下表中的链接列v$databaseall_usersdba_usersv$session

采纳答案by Sanjaya Balasuriya

To link V$SESSION and DBA_USERS, use "Usernanme" column from both the views. It'll return details on user session.

要链接 V$SESSION 和 DBA_USERS,请使用两个视图中的“Usernanme”列。它将返回有关用户会话的详细信息。

select D.USERNAME, D.USER_ID, V.SID, V.STATUS from v$session v, dba_users d where V.USERNAME=D.USERNAME;

选择 D.USERNAME, D.USER_ID, V.SID, V.STATUS from v$session v, dba_users d where V.USERNAME=D.USERNAME;

If you need details about sessions created for background processes also, then join by "User#" from V$SESSION and "User_ID" from DBA_USERS.

如果您还需要有关为后台进程创建的会话的详细信息,请通过来自 V$SESSION 的“User#”和来自 DBA_USERS 的“User_ID”加入。

select D.USERNAME, D.USER_ID, V.SID, V.STATUS from v$session v, dba_users d where V.USER#=D.USER_ID;

选择 D.USERNAME, D.USER_ID, V.SID, V.STATUS from v$session v, dba_users d 其中 V.USER#=D.USER_ID;

回答by Andreas Fester

To query users which are defined in the database, you can use the all_usersview. For example, to select all users who start with aor A, use

要查询数据库中定义的用户,可以使用all_users视图。例如,要选择以a或开头的所有用户A,请使用

SELECT * 
FROM all_users 
WHERE NLS_UPPER(username) LIKE 'A%';

To query current sessions for a particular user, you can use the v$sessionview. For example, to select all current sessions which are established for a user who starts with aor A, use

要查询特定用户的当前会话,您可以使用该v$session视图。例如,要选择为以a或开头的用户建立的所有当前会话A,请使用

SELECT * 
FROM v$session
WHERE NLS_UPPER(username) LIKE 'A%';

回答by Coding Duchess

select username from all_users;

or

select username from all_users where ...;

There are 3 different sets of views ALL_, DBA_, and USER_.

有 3 组不同的视图 ALL_、DBA_ 和 USER_。

ALL_ views display all the information accessible to the current user, i.e. it can looks at all the shcemas the user has permissions to, DBA_ views display infor for the entire database and is intended only for admins. Then USER_ views display info from the schema of the current user.

ALL_ 视图显示当前用户可以访问的所有信息,即它可以查看用户有权访问的所有 shcemas,DBA_ 视图显示整个数据库的信息并且仅供管理员使用。然后 USER_ 视图显示来自当前用户架构的信息。

Sounds like you need ALL_USERS

听起来你需要 ALL_USERS