比较三个数据库并显示差异 [英] To compare three databases and show the difference

查看:71
本文介绍了比较三个数据库并显示差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我想比较3个数据库并显示它的不同。

任何人都可以帮我理解它背后的逻辑?

我应该如何开始比较。



示例:



假设我有3个数据库。



1)

第一个数据库有4个表

第二个数据库有2个表格和第3个数据库有4个表格

所以在这种情况下,第2个数据库中缺少2个表格。





2)所有数据库都有4个表,然后它应该检查结构的变化,如果有的话没有。列或数据类型。



3)如果数据库有触发器或函数,则应逐行比较,差异应用颜色突出显示。





希望这能解释我的问题。



问候,

Hi,

I want to compare 3 databases and show its difference.
Can anyone help me to understand the logic behind it?
Like how should i start the comparison.

Example:

Suppose i have 3 databases.

1)
1st database has 4 tables
2nd database has 2 tables and 3rd database has 4 tables
so in this case the difference is 2 tables are missing in 2nd database.


2) All the databases have 4 tables then it should check for change in structure if any like no. of columns or data types.

3)If databases have triggers or functions then those should be compared line by line and difference should be highlighted with colors.


Hope this explains my questions.

Regards,

推荐答案

很多年前我写了一个应用来做到这一点。这是针对SQL Server的,我们有Dev,Test和Prod环境。为了让生活更轻松,我一次只比较2个。您可以使用系统表执行所有操作。



我比较了数据库中的对象(表格,存储过程,函数,视图等)我会发现其中一个丢失了。我把它分解成类型只是为了让UI更容易。



如果表结构不同我会把链接显示差异,Varchar(5)和Varchar (10)可以产生巨大的差异!



我甚至比较了存储过程中的文本来显示不同的文本。



所以你必须比较存在的和缺少的东西,然后比较你想的那些项目。我最大的建议是一次只比较2个以节省大量工作。



存储过程,函数和触发器的所有文本都存储在系统表使您可以轻松进行SQL字符串比较。
Many years ago I wrote an app to do that. It was against SQL Server and we had a Dev, Test, and Prod environments. To make life easier I only compared 2 at a time. You can do all that using the system tables.

I compared objects in the databases (tables, Stored Procedures, Functions, views etc) I would find what was missing in one then the other. I had it broken down into types just to make the UI easier.

If table structure was different I would put links to display the differences, Varchar(5) and Varchar(10)can make a huge difference!

I was even comparing the text in the stored procedures to display the ones that were different.

So you have to compare what exists in and what is missing, then compare the items like you were thinking. My biggest recommendation would be to only compare 2 at a time to save yourself a lot of work.

All the text for the stored procedures, functions and triggers is stored in the system tables so you can do easy SQL string compares.


这篇关于比较三个数据库并显示差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆