Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Query Database Name in Oracle SQL Developer?

How do I query the database name in 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? 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. 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.

like image 372
Xonatron Avatar asked Jan 23 '12 20:01

Xonatron


People also ask

What is the database name in oracle?

Oracle Database (commonly referred to as Oracle DBMS, Oracle Autonomous Database, or simply as Oracle) is a multi-model database management system produced and marketed by Oracle Corporation.

How do I find the database name in oracle 12c?

Answer: You can retrieve the instance name and database name using the sys_context function.

How do I find the global database name in oracle?

You can find out what the global name is for your database by executing the following query from SQL*Plus: select * from global_name; It is also possible to alter the global name of an existing database with the following command: alter database rename global_name to <db_name.


1 Answers

Once I realized I was running an Oracle database, not MySQL, I found the answer

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.

like image 124
Xonatron Avatar answered Sep 23 '22 15:09

Xonatron