Click here to Skip to main content
Licence 
First Posted 20 Jul 2004
Views 98,122
Bookmarked 37 times

Schema Compare Tool for Oracle

By | 20 Jul 2004 | Article
This small VB.NET application allows you to compare Oracle database schemas against one another. This is very helpful when making sure your development instance is the same as your production instance; especially when implementing front-end changes.
 
Part of The SQL Zone sponsored by
See Also

Sample Image - OracleSchemaCompare.jpg

Introduction

This small VB.NET application allows you to compare Oracle database schemas against one another. This is very helpful when making sure your development instance is the same as your production instance; especially when implementing front-end changes.

Background

In rolling out a multi-tiered application, you may have to implement new or changed .NET assemblies, user-interfaces, and database changes in a synchronized fashion. You often need to make sure your production database has the same structure as the development or test instance before rolling out the .NET changes. How many times have you rolled out a .NET change and forgot that it required a database change like creating a view or modifying a stored procedure?

That's where this tool comes in handy.

Using the Tool

This VB.NET application comes ready to run. All you need is the .NET Framework 1.1 installed and the appropriate Oracle SQL*Net drivers because the application uses the System.Data.OracleClient for database access.

The first step is to create a "baseline" structure in XML. This is typically generated from the most up-to-date database and is used to compare other databases. You can use this single baseline to compare several other instances. This is helpful when you have to rollout changes to multiple install sites that all need to have the same database structure.

In the "Create Baseline" area, enter the database connection info and click "Build". This will query the Oracle data dictionary tables and build an XML file named "Baseline.xml" in your working directory. If you have already built a baseline, the application will read the XML file on startup and display the overview information as shown above.

Once the baseline has been generated, the "Compare Against Baseline" area becomes enabled allowing you to enter database log on criteria and click "Compare". The application will query the same data dictionary tables for the "Compare" schema and compare the results against the baseline. During the comparison, a log file is created named "ReconcileLog.txt" in your working directory.

After the compare is complete, the reconcile log is displayed in Notepad for your review. An example is given below:

In this example, we can see that the compared schema is missing a table named "NEWFUNCTB". We also see that the compared schema has an extra view that is not in the baseline named "PM_TRENDS_V", and that a column on the "WORKFLOWSTEP" table needs to be added. Although the actual code inside of stored procedures is not examined, we can see that the number of lines is different in the "BE_ACCESSGROUP" package, and can assume that the package probably contains changes.

The application compares the following database structure elements:

  • TABLES: Name, Columns, Column Data Types, Column Lengths, Column Nullable
  • VIEWS: Name, SQL Length
  • SEQUENCES: Name, Min Value, Max Value, Increment By, Cycle Flag
  • TRIGGERS: Name, Type, Triggering Event, Table Name
  • CONSTRAINTS: Name, Table Name, Type, Delete Rule
  • INDEXES: Name, Table Name, Uniqueness
  • DBMS_JOBS: What, Interval
  • PROCEDURES: Name
  • PACKAGES: Name, Line Count

Once the application has been run, these files will exist in the working directory:

  • Baseline.xml: Represents baseline schema. It can be read by a DataSet using ReadXml("Baseline.xml") if you want to use the data in your own application.
  • Config.xml: Contains the last usernames, passwords (encrypted), and databases. This is read on startup to populate the form fields.
  • ReconcileLog.txt: The last compare's results.

Points of Interest

It should be noted that this application compares database structure, not data. So if you need to add records to a table, for example, this application won't pick that change up.

I've tested this application on Oracle8i and Oracle9i. Earlier versions may or may not work.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Barry Etter

Web Developer

United States United States

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionLicense PinmemberWilcoBT22:26 3 Aug '09  
GeneralThe BIN$ Problem PinmemberPerry Tribolet10:33 3 Aug '09  
GeneralGreat Job! Pinmemberfiordel8:22 15 Apr '09  
GeneralExcellent! Pinmembermpemberton3:55 11 Sep '08  
Generalcompare schema tool PinmemberLWarne9:26 16 May '08  
Questiongood job!!! how about all the other objects? PinmemberPeter Teoh Teik Huat14:44 13 Mar '08  
GeneralExcellent Work PinmemberMohamed Kaleemullah2:18 26 Nov '07  
QuestionComparing MS SQL DB Pinmemberzeevf2:03 4 Aug '07  
GeneralNice Apps ! Pinmemberhankadp4:55 18 Jul '07  
Generaloracle.dataAccess.client, oracle.dataAccess.dll PinmemberSilver-Grey5:56 13 Nov '06  
QuestionNice Tool but not giving me details about the "Column Diff" Pinmemberredearth6:04 27 Oct '06  
GeneralHigh Memory usage for this tool Pinmemberprateek_parashar2:09 28 Aug '06  
GeneralOS Question PinmemberThe Magnet6:25 16 Aug '06  
GeneralVery useful tool Pinmembersprash255:59 10 May '06  
GeneralExcellent Tool Pinmemberkevingay8:13 6 Feb '06  
Generalproject doesnot run. Pinmembernavneet_it219:11 28 Sep '05  
GeneralSchema and Login might not match Pinmemberraineyd4:52 6 Jan '05  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120517.1 | Last Updated 21 Jul 2004
Article Copyright 2004 by Barry Etter
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid