如何使用 SQL*Plus 在 Oracle 11g 中显示数据库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3004171/
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-10 02:37:38  来源:igfitidea点击:

How to display databases in Oracle 11g using SQL*Plus

oracleoracle11gsqlplus

提问by Nubkadiya

With help of this command show databases;I can see databases in MySQL.

在这个命令的帮助下,show databases;我可以看到MySQL 中的数据库。

How to show the available databases in Oracle?

如何在Oracle 中显示可用的数据库?

采纳答案by dpbradley

You can think of a MySQL "database" as a schema/user in Oracle. If you have the privileges, you can query the DBA_USERSview to see the list of schemas:

您可以将 MySQL“数据库”视为 Oracle 中的模式/用户。如果您有权限,您可以查询DBA_USERS视图以查看模式列表:

SELECT * FROM DBA_USERS;

回答by Shan

SELECT NAME FROM v$database;shows the database name in oracle

SELECT NAME FROM v$database;在 oracle 中显示数据库名称

回答by Thomas Bratt

Oracle does not have a simple database model like MySQL or MS SQL Server. I find the closest thing is to query the tablespaces and the corresponding users within them.

Oracle 没有像 MySQL 或 MS SQL Server 这样的简单数据库模型。我发现最接近的是查询表空间和其中的相应用户。

For example, I have a DEV_DB tablespace with all my actual 'databases' within them:

例如,我有一个 DEV_DB 表空间,其中包含我所有的实际“数据库”:

SQL> SELECT TABLESPACE_NAME FROM USER_TABLESPACES;

Resulting in:

导致:

SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS
EXAMPLE
DEV_DB
SYSTEM
SYSAUX
UNDOTBS1
TEMP
USERS
EXAMPLE
DEV_DB

It is also possible to query the users in all tablespaces:

也可以查询所有表空间中的用户:

SQL> select USERNAME, DEFAULT_TABLESPACE from DBA_USERS;

Or within a specific tablespace (using my DEV_DB tablespace as an example):

或在特定表空间内(以我的 DEV_DB 表空间为例):

SQL> select USERNAME, DEFAULT_TABLESPACE from DBA_USERS where DEFAULT_TABLESPACE = 'DEV_DB';

ROLES DEV_DB
DATAWARE DEV_DB
DATAMART DEV_DB
STAGING DEV_DB

回答by Jonathan

Maybe you could use this view, but i'm not sure.

也许你可以使用这个视图,但我不确定。

select * from v$database;

But I think It will only show you info about the current db.

但我认为它只会向您显示有关当前数据库的信息。

Other option, if the db is running in linux... whould be something like this:

其他选项,如果数据库在 linux 中运行......应该是这样的:

SQL>!grep SID $TNS_ADMIN/tnsnames.ora | grep -v PLSExtProc

回答by BongSey

I am not clearly about it but typically one server has one database (with many users), if you create many databases mean that you create many instances, listeners, ... as well. So you can check your LISTENERto identify it.

我不是很清楚,但通常一台服务器有一个数据库(有很多用户),如果你创建了很多数据库,就意味着你创建了很多实例、监听器等等。所以你可以检查你的LISTENER来识别它。

In my testing I created 2 databases (dbtestand dbtest_1) so when I check my LISTENER status it appeared like this:

在我的测试中,我创建了 2 个数据库(dbtestdbtest_1),所以当我检查我的 LISTENER 状态时,它看起来像这样:

lsnrctl status

....

STATUS of the LISTENER

.....

(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.10.20.20)(PORT=1521)))

Services Summary...

Service "dbtest" has 1 instance(s).

Instance "dbtest", status READY, has 1 handler(s) for this service...

Service "dbtest1XDB" has 1 instance(s).

Instance "dbtest1", status READY, has 1 handler(s) for this service...

Service "dbtest_1" has 1 instance(s).

Instance "dbtest1", status READY, has 1 handler(s) for this service... The command completed successfully

....

听众的状态

.....

(描述=(地址=(协议=tcp)(主机=10.10.20.20)(端口=1521)))

服务概要...

服务“dbtest”有 1 个实例。

实例 "dbtest", 状态 READY, 具有此服务的 1 个处理程序...

服务“dbtest1XDB”有 1 个实例。

实例 "dbtest1", 状态 READY, 具有此服务的 1 个处理程序...

服务“dbtest_1”有 1 个实例。

实例 "dbtest1", 状态为 READY, 具有此服务的 1 个处理程序...命令成功完成