Solved

How to get object discription from databases  using a script.

Posted on 2014-07-22
3
293 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Suggested Solutions

This post first appeared at Oracleinaction  (http://oracleinaction.com/undo-and-redo-in-oracle/)by Anju Garg (Myself). I  will demonstrate that undo for DML’s is stored both in undo tablespace and online redo logs. Then, we will analyze the reaso…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Via a live example, show how to take different types of Oracle backups using RMAN.
This video shows how to recover a database from a user managed backup

744 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

13 Experts available now in Live!

Get 1:1 Help Now