Oscar Castillo
I bet almost every DBA has at times desperatelywanted to be able to compare data and structure between database tables, or even whole databases for that matter. Wouldn’t it be nice to have a stored procedure that uses only two parameters -- the nameof the first database and the name of the second database -- that compares structures of the databases and the data in them, and tells you the differences between them?
While it is relativelysimple to compare database or table structures, either programmatically or manually, comparing data is not so easy. Unlike comparing structures, comparing data between tables or databases is one that youcan’t easily do manually. I’m not saying that nobody likes this sort of intellectual work, comparing table-by-table, column-by-column in bulky queries using JOINs and NOT IN. I’m saying it’s usuallyphysically impossible to achieve if the databases are not diminutive, and mistakes are unavoidable.
What Does It Take to Write Such a Stored Procedure?
Well, let’s compare data structures and databetween two databases programmatically. If we let ourselves think a bit about the implementation, we will come to a quick solution: create a cycle through all tables and compose SELECTs to obtain thedifferences. But when we start to put this primitive into practice, we run into a long series of “Oops!” Let me list just some of them I came upon while creating my SP to compare database structures...
Regístrate para leer el documento completo.