Friday, February 1, 2008

Schema Comparison

I know there are many tools out there that gives the schema comparison in probably 3 or 4 clicks. But the problem that I have faced is, when the table names are different, alright not completely different but with one or two standard characters difference viz., prefixing with "t_" or appending with "_x" or something, then the tools (atleast that i know of) are not good any more. Thus made me to go back to my old days to write my own script to achieve this.

Here is my scenario:
The environment that i am working on is going thru some major migration and integration process and we end up in renaming all the tables to prefix with "t_" and then create a synonym so that the existing applications dont have to change completely. So, that said, we have an existing database with regular names and the new one with "t_".
Guess what, TOAD can not compare these schemas anymore since all table names are different.

Basically, this is what i have done to achieve this:
created a tableA using user_tab_columns data dictionary data from existing and
created a tableB using user_tab_columns data dictionary data from the new schema over the database link.
One can question, why create these tables instead of directly accessing them thru database links? Answer is, there are few columns in this data dictionary that can be accessed and compared via db links. So, created these tables.

Once the tables are there, you can do what ever you want and however you want to compare correct. So, here is my script:

Not sure if I can attach a file here but let me see (as this is first blog :( ).
Well, cant upload a file so published another post and linking here:

No comments:

Post a Comment