How to Query Database Name in Oracle SQL Developer?

前端 未结 7 1539
自闭症患者
自闭症患者 2020-12-29 20:28

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(

相关标签:
7条回答
  • 2020-12-29 20:43

    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.

    0 讨论(0)
  • 2020-12-29 20:44

    DESCRIBE DATABASE NAME; you need to specify the name of the database and the results will include the data type of each attribute.

    0 讨论(0)
  • 2020-12-29 20:46

    try this:

    select * from global_name;
    
    0 讨论(0)
  • 2020-12-29 20:55

    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.

    0 讨论(0)
  • 2020-12-29 20:59

    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

    0 讨论(0)
  • 2020-12-29 21:05

    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

    describe v$database;
    

    and select the columns that you want to see;

    0 讨论(0)
提交回复
热议问题