[英]How to Query Database Name in Oracle SQL Developer?
How do I query the database name in Oracle SQL Developer? 如何在Oracle SQL Developer中查询数据库名称? I have tried the following and they all fail:
我尝试了以下内容,但都失败了:
SELECT DB_NAME();
SELECT DATABASE();
Why do these basic MySQL queries fail in SQL Developer? 为什么这些基本的MySQL查询在SQL Developer中失败? Even this one fails too:
即使这个也失败了:
show tables;
EDIT: I can connect to the database and run queries such as: 编辑:我可以连接到数据库并运行查询,如:
select * from table_name_here;
EDIT 2: The database type is Oracle
, this is why MySQL
queries are failing. 编辑2:数据库类型是
Oracle
,这就是MySQL
查询失败的原因。 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.
我将把这个问题留给其他像我一样迷失的问题。
Once I realized I was running an Oracle database, not MySQL, I found the answer 一旦我意识到我运行的是Oracle数据库,而不是MySQL,我找到了答案
select * from v$database;
or 要么
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 。
尝试这个:
select * from global_name;
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; 并选择要查看的列;
I know this is an old thread but you can also get some useful info from the V$INSTANCE
view as well. 我知道这是一个旧线程,但你也可以从
V$INSTANCE
视图中获得一些有用的信息。 the V$DATABASE
displays info from the control file, the V$INSTANCE
view displays state of the current instance. V$DATABASE
显示控制文件中的信息, V$INSTANCE
视图显示当前实例的状态。
To see database name, startup; 要查看数据库名称,启动;
then type show parameter db_name; 然后输入show parameter db_name;
DESCRIBE DATABASE NAME; 描述数据库名称; you need to specify the name of the database and the results will include the data type of each attribute.
您需要指定数据库的名称,结果将包括每个属性的数据类型。
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?). 检查您是否可以实际连接到DB(放置驱动程序?在创建时测试conn?)。
If so, try runnung those queries with F5 如果是这样,请尝试使用F5运行这些查询
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.