Solved

How to get object discription from databases  using a script.

Posted on 2014-07-22
3
296 Views
Last Modified: 2014-11-05
Hi,
I have a data base having 160 tables. I need a SQL script which can output table name and its description
accessing oracle metadata.

The script should spool output the Describe Table for each and every table  in following way.

1) desc TableA
    id1      number
    c1       varchar2(150)
    n1      nuber(p,s)
    d1     date
2) desc TableB
    id2      number
     n2      nuber
    c2       varchar2(150)
    n3      nuber(p,s)
    d2    date

Basically I want to compare the same set of tables between the 2 data bases to find the deviations since they exists in our environment.
deviations like 2 different data types
more columns in one DB and less in other for the same table.
If I can spool information in a text file I can find diff using a tool. If there is another easier way without creating db_links I will go for it.
Please help me to find a way without comparing table by table manually.
Thanks

I
0
Comment
Question by:Akai123
3 Comments
 
LVL 24

Accepted Solution

by:
chaau earned 500 total points
ID: 40213216
The easiest way to do this is to use a '*' wildcard for the describe command, like this:
DESCRIBE '*';

Open in new window


Bonus answer:
To get the list of all user tables use this command:
select tablespace_name, table_name from user_tables;

Open in new window

To get the list of all tables in the database use:
select tablespace_name, table_name from dba_tables;

Open in new window

To get the list of all columns for all tables use:
select * from ALL_TAB_COLUMNS order by owner, table_name, column_name;

Open in new window

To get the list of all columns for user tables use:
select * from USER_TAB_COLUMNS order by table_name, column_name;

Open in new window

I think this last query will give you a nice list to work with your favourite text comparison utility
0
 
LVL 16

Expert Comment

by:Wasim Akram Shaik
ID: 40213423
you should use something like this.. get the output of the below query from both databases against the user.

this will provide the output you are looking for

select table_name,column_name,data_type from dba_tab_columns where owner='USER_NAME'
order by table_name,column_name
0
 
LVL 29

Expert Comment

by:MikeOM_DBA
ID: 40214920
I recommend SchemaSpy, it will create nice HTML documentation and it's released under GNU General Public License.
;)
Or...you can re-invent the wheel.
:p
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
I remember the day when someone asked me to create a user for an application developement. The user should be able to create views and materialized views and, so, I used the following syntax: (CODE) This way, I guessed, I would ensure that use…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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.

910 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now