Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. 2 queries from Oracle

2 queries from Oracle

Scheduled Pinned Locked Moved Database
databasesql-serveroraclequestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • _ Offline
    _ Offline
    _Flaviu
    wrote on last edited by
    #1

    Hello all. If you own an Oracle DB, could you provide me two queries? First, get database_id and name for every database, something like this (in MSSQL):

    SELECT database_id, name FROM sys.databases ORDER BY 2

    and the second one, that provide every table from a database, something like that (in MSSQL):

    SELECT table_name FROM %s.information_schema.tables ORDER BY 1

    where %s is the database name taken from the first query. Thank you.

    S 1 Reply Last reply
    0
    • _ _Flaviu

      Hello all. If you own an Oracle DB, could you provide me two queries? First, get database_id and name for every database, something like this (in MSSQL):

      SELECT database_id, name FROM sys.databases ORDER BY 2

      and the second one, that provide every table from a database, something like that (in MSSQL):

      SELECT table_name FROM %s.information_schema.tables ORDER BY 1

      where %s is the database name taken from the first query. Thank you.

      S Offline
      S Offline
      scottgp
      wrote on last edited by
      #2

      In Oracle, the equivalent for SQL Server's information_schema or sys tables would be the DICTIONARY and dynamic performance views - ([https://docs.oracle.com/cd/E11882\_01/server.112/e40540/datadict.htm#CNCPT002\](https://docs.oracle.com/cd/E11882\_01/server.112/e40540/datadict.htm#CNCPT002)) Your first query doesn't make sense in an Oracle context since in Oracle you only connect to one database at a time. The second could be (to list the tables in the connected database): SELECT * FROM ALL_TABLES; SELECT * FROM DBA_TABLES; depending on your rights. See the link for the difference.

      _ 1 Reply Last reply
      0
      • S scottgp

        In Oracle, the equivalent for SQL Server's information_schema or sys tables would be the DICTIONARY and dynamic performance views - ([https://docs.oracle.com/cd/E11882\_01/server.112/e40540/datadict.htm#CNCPT002\](https://docs.oracle.com/cd/E11882\_01/server.112/e40540/datadict.htm#CNCPT002)) Your first query doesn't make sense in an Oracle context since in Oracle you only connect to one database at a time. The second could be (to list the tables in the connected database): SELECT * FROM ALL_TABLES; SELECT * FROM DBA_TABLES; depending on your rights. See the link for the difference.

        _ Offline
        _ Offline
        _Flaviu
        wrote on last edited by
        #3

        Thank you Scott, so, in Oracle it is not possible to list all databases ?

        S 1 Reply Last reply
        0
        • _ _Flaviu

          Thank you Scott, so, in Oracle it is not possible to list all databases ?

          S Offline
          S Offline
          scottgp
          wrote on last edited by
          #4

          I confess I use SQL Server more these days than Oracle, but the only possible option I can find that would let you see multiple databases seems to be if you're using something like Enterprise Manager Cloud Control - [Extract the list of all databases with server and OS version of Oracle Enterprise Manager Cloud Control repository - My DBA World]([https://www.mydbaworld.com/extract-databases-server-os-version-of-oem-repository/\])

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups