Solved

How to get object discription from databases  using a script.

Posted on 2014-07-22
3
302 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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

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

Suggested Solutions

Note: this article covers simple compression. Oracle introduced in version 11g release 2 a new feature called Advanced Compression which is not covered here. General principle of Oracle compression Oracle compression is a way of reducing the d…
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 shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to restore a database from backup after a simulated disk failure using RMAN.

831 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