如何在 Oracle SQL Developer 中查询数据库名称?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8978047/
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
How to Query Database Name in Oracle SQL Developer?
提问by Xonatron
How do I query the database name in Oracle SQL Developer? I have tried the following and they all fail:
如何在 Oracle SQL Developer 中查询数据库名称?我尝试了以下方法,但都失败了:
SELECT DB_NAME();
SELECT DB_NAME();
SELECT DATABASE();
SELECT DATABASE();
Why do these basic MySQL queries fail in SQL Developer? Even this one fails too:
为什么这些基本的 MySQL 查询在 SQL Developer 中会失败?甚至这个也失败了:
show tables;
show tables;
EDIT:I can connect to the database and run queries such as:
编辑:我可以连接到数据库并运行查询,例如:
select * from table_name_here;
select * from table_name_here;
EDIT 2:The database type is Oracle
, this is why MySQL
queries are failing. I thought it was related to the database client not the database itself. I was wrong. I'll leave the question as is for other as lost as I was.
编辑 2:数据库类型是Oracle
,这就是MySQL
查询失败的原因。我认为这与数据库客户端有关,而不是数据库本身。我错了。我会像我一样迷失了其他人的问题。
回答by Xonatron
Once I realized I was running an Oracle database, not MySQL, I found the answer
一旦我意识到我运行的是 Oracle 数据库,而不是 MySQL,我找到了答案
select * from v$database;
select * from v$database;
or
或者
select ora_database_name from dual;
select ora_database_name from dual;
Try both. Credit and source goes to: http://www.perlmonks.org/?node_id=520376.
两个都试试。信用和来源:http: //www.perlmonks.org/? node_id= 520376。
回答by junaling
try this:
尝试这个:
select * from global_name;
回答by rainu
You can use the following command to know just the name of the database without the extra columns shown.
您可以使用以下命令只知道数据库的名称,而无需显示额外的列。
select name from v$database;
If you need any other information about the db then first know which are the columns names available using
如果您需要有关 db 的任何其他信息,则首先知道哪些是可用的列名
describe v$database;
and select the columns that you want to see;
并选择要查看的列;
回答by JamesN
I know this is an old thread but you can also get some useful info from the V$INSTANCE
view as well. the V$DATABASE
displays info from the control file, the V$INSTANCE
view displays state of the current instance.
我知道这是一个旧线程,但您也可以从V$INSTANCE
视图中获取一些有用的信息。的V$DATABASE
从控制文件显示信息,该V$INSTANCE
视图显示状态下的电流实例的。
回答by EMMANUEL NICHOULAUS MNYASA
DESCRIBE DATABASE NAME; you need to specify the name of the database and the results will include the data type of each attribute.
描述数据库名称;您需要指定数据库的名称,结果将包括每个属性的数据类型。
回答by Vishnu
To see database name, startup;
查看数据库名称,启动;
then type show parameter db_name;
然后键入显示参数 db_name;
回答by Alfabravo
Edit: Whoops, didn't check your question tags before answering.
编辑:哎呀,在回答之前没有检查你的问题标签。
Check that you can actually connect to DB (have the driver placed? tested the conn when creating it?).
检查您是否可以实际连接到数据库(是否放置了驱动程序?在创建时测试了连接?)。
If so, try runnung those queries with F5
如果是这样,请尝试使用 F5 运行这些查询