Solved

Query Oracle for information on a Database

Posted on 2014-03-03
10
271 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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Truncate is a DDL Command where as Delete is a DML Command. Both will delete data from table, but what is the difference between these below statements truncate table <table_name> ?? delete from <table_name> ?? The first command cannot be …
Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
Via a live example show how to connect to RMAN, make basic configuration settings changes and then take a backup of a demo database
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

749 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