Solved

Query Oracle for information on a Database

Posted on 2014-03-03
10
272 Views
Last Modified: 2014-03-04
I am in the process of developing an Application Catalog for our small group.  Part of the App Catalog is to show which databases and tables are used by the application.  I am planning on having a database that contains the Database names that our group currently works with.  What I want to do is given a Database name, query Oracle to get all the information about that database.  For example, I would like to get the following information:
* Tables in the database
* Field definitions for each table in the database
* Views in the database
* Indexes on each table
* Triggers used in the database and the tables associated with the triggers
* Sequences defined in the table
* Materialized Views
* Synonyms
* Public Synonyms
* any other info for the database

I would also like to be able to store the unique id associated with each table in the database so I can assign tables to specific applications.  For example:

Application 1 defined in the Application Catalog uses the Table1 and Table2 tables from the Test database.  The Test database contains 15 tables.  I want to be able to store a value in my table for the Application Catalog that shows the app uses  Table1 and Table2.  I don't want to store the actual table names because they are already defined in ORACLE and I don't want to "recreate the wheel".

I hope this makes sense and any help is greatly appreciated!
0
Comment
Question by:dyarosh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +2
10 Comments
 
LVL 29

Accepted Solution

by:
MikeOM_DBA earned 500 total points
ID: 39901725
Each oracle database has a view on which you could base your catalog, just click on the link: ALL_OBJECTS

Based on this view you can drill down to the Data Dictionary Views for each object
0
 

Author Comment

by:dyarosh
ID: 39901743
Is there a way to do this from a c# program?
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39901789
You can do whatever you want with C#.  I suggest you use ODP.Net as the data provider.

You can download it from here:
http://www.oracle.com/technetwork/topics/dotnet/downloads/net-downloads-160392.html?ssSourceSiteId=ocomen

That said:  Why do you want to mix objects within the same schema for different applications?

What you are describing doesn't make any sense.

Create a new schema for each application.  If the apps need to reference objects in the other schema, just create a synonym and grant the proper privs.
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 39901790
And that the account you will use to login must have SELECT ANY DICTIONARY privilege.
0
 

Author Comment

by:dyarosh
ID: 39901813
Ok.  This is being used to associate databases with an application so we can tell when a database is no longer needed.
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39901821
>>associate databases with an application so we can tell when a database is no longer needed.

I think you are not familiar with Oracle architecture.

In Oracle a database refers to the files on disk.

A schema is a database user that owns objects.

How do you plan on knowing when a set of database objects is no longer in use?
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 39901962
that's reverse logic
you need to analyze your c programs to see which tables you still need

if you have functionality which is almost never used, like year-end calculations,
checking the database for usage you might miss those tables and drop them

if you want to know if a database is no longer needed
add a logon trigger to it and log all the entries in a table
if no one has logged on for six months ... then it wasn't needed in those six months

if you were to enter the module name for all your apps in the session info,
you might be able to catch about 80% of the data you want
0
 
LVL 23

Expert Comment

by:David
ID: 39901983
Just my two cents, but is such an effort going to be useful to your audience?  Like the previous comment, is this something worth maintaining?

When I wear my data architect hat, I'm more likely to go after a relational model / CASE diagram, and business rules so that the developers know what constraints to include.
0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 39903281
Want to know if a schema (database) is being used or not? -- Change the password and be ready to listen who complains.
:p
0
 

Author Closing Comment

by:dyarosh
ID: 39903381
Thank you.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Via a live example, show how to take different types of Oracle backups using RMAN.

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question