DBDiff: a C# program to compare two databases

In one of my current projects I have to import an Oracle database dump into a development database every two weeks. But more than once there were tables missing, columns have been changed, or indices have been removed in the new dump. Of course, that led to problems with the programs that used the database.

To be able to find the differences between the old and the new database I wrote a small C# program that “diffs” two databases. It generates a textfile containing

  • a list of all tables
  • including the number of rows per table
  • a list of all indexes
  • a list of all columns and their configuration

Furthermore, it compares two of these text files and produces an output file like this:

== Missing tables ==

== Added tables ==

= Less rows =
TABLE3: 123 -> 100

= Equal number of rows =
TABLE4: 17 -> 17

= More rows =
TABLE5: 123 -> 234

== Missing indexes ==

== Added indexes ==

== Missing Columns ==

== Added Columns ==

So, before I import the new dump, I create a textfile with DBDiff that contains the current database state. After the import I create another one and compare it to the old file giving me all the changes to the database structure. Of course, the tool could also be used to compare a production database to a development database.

Here are two screenshot showing the tool in action:

DBDiff dumping database information
DBDiff comparing two result text files


You can download the program including its source code here:

All needed configuration (DSN, credentials etc.) is done in DBDiff.exe.config. The database needs to be configured and reachable as an ODBC source.

Über Stefan

Polyglot Clean Code Developer

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax