SQL 如何找到两个数据库之间的差异?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8987856/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I find the differences between two databases?
提问by Rachel
I am trying to copy changes from DatabaseA to DatabaseB, however I don't know exactly what those changes were.
我试图将更改从 DatabaseA 复制到 DatabaseB,但是我不知道这些更改究竟是什么。
Is there a SQL script around that will find objects that are different between the databases, then generate a script to update DatabaseB to match DatabaseA?
是否有一个 SQL 脚本可以找到数据库之间不同的对象,然后生成一个脚本来更新 DatabaseB 以匹配 DatabaseA?
I'm using SQL 2005, and I don't want to lose the existing data in DatabaseB
我使用的是 SQL 2005,我不想丢失 DatabaseB 中的现有数据
采纳答案by Vinnie
There are schema and data compare tools from Red Gate that do exactly what you're looking for. There are also some others in the market, like Apex SQL Compare. But, if you're fortunate enough to have Visual Studio 2010 Premium or Ultimate edition, there is a compare tool built in to those versions.
Red Gate 提供的模式和数据比较工具完全符合您的要求。市场上还有其他一些产品,例如 Apex SQL Compare。但是,如果您有幸拥有 Visual Studio 2010 Premium 或 Ultimate 版,那么这些版本内置了一个比较工具。
http://www.apexsql.com/default.aspx
http://www.apexsql.com/default.aspx
http://www.red-gate.com/products/sql-development/sql-compare
http://www.red-gate.com/products/sql-development/sql-compare
http://msdn.microsoft.com/en-us/library/dd193250.aspx
http://msdn.microsoft.com/en-us/library/dd193250.aspx
Otherwise, you're going to have to use linked servers and a lot of querying against the INFORMATION_SCHEMA.
否则,您将不得不使用链接服务器并对 INFORMATION_SCHEMA 进行大量查询。
Some of those software tools you can use on a trial basis and probably get what you need without buying a full license.
您可以试用其中一些软件工具,并且可能无需购买完整许可证即可获得所需内容。
回答by Gustavo F
Try DBComparer.
试试DBComparer。
回答by Mike Nakis
I have used "SQL Compare" and "SQL Data Compare" by Red Gate Software, and they work like a charm. I do not suppose that there exists a script to do the same job, because if it existed, then there would be no use and no market for these products.
我使用了Red Gate Software 的“SQL 比较”和“SQL 数据比较” ,它们的工作原理非常棒。我不认为存在一个脚本来做同样的工作,因为如果它存在,那么这些产品就没有用处,也没有市场。
回答by ChrisBD
I use AdeptSQL Diff. It's a commercial product found at www.adeptsql.com. I think that the trial licence is for 30 days or 50 startups.
我使用 AdeptSQL Diff。它是一种商业产品,可在www.adeptsql.com 上找到。我认为试用许可证适用于 30 天或 50 家初创公司。