合并两个 SQL Server 数据库
您好,我有这种情况:
- SQL Server 1(生产)带有对象 A、B、C
- SQL Server 2(开发)带有对象 A、B、C、D、E、F、G、H、I。
我想知道我如何保存 SQL Server 1 的每个对象(A、B、C),但同时我想添加 SQL Server 2 中的每个新对象。在 SQL Server 2 中 A,B,C
具有相同的模式,但假数据遵循 SQL 中的相同对象服务器 1,所以我无法对 SQL Server 2 进行完整备份并在 SQL Server 1 中还原它。
两台服务器都运行 SQL Server 2008。
我知道显然有一个智能程序可以执行此操作,但我在 SQL Server 管理方面的一点经验使得我瞎了!
预先感谢您的任何帮助!
Hi I have this situation:
- SQL Server 1 (production) with obj A, B, C
- SQL Server 2 (development) with objects A, B, C, D, E, F, G, H, I.
I would like to know how I can hold every objects of SQL Server 1 (A,B,C) but at the same time I want to add every new objects from SQL Server 2. In SQL Server 2 A,B,C
have same schema but fake data respect the same objects in SQL Server 1 so I can't make a full backup of SQL Server 2 and restore it in SQL Server 1.
Both server are running SQL Server 2008.
I know there obviously a smart procedure to do this but my small experience in SQL Server management makes me blind!
Thanks in advance for any help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你需要一些好工具!例如:
Red-Gate SQL Compare 可以帮助您比较和同步数据库的结构(例如表、视图、过程、约束等数据库对象)
Red-Gate SQL 数据比较 帮助您比较和同步表中的数据,例如在查找表和系统表甚至您的实际数据表
You need some good tools! Like:
Red-Gate SQL Compare helps you compare and sync the structure of your databases (e.g. database objects like tables, views, procs, constraints etc.)
Red-Gate SQL Data Compare helps you compare and sync your data in your tables, e.g. in your lookup and system tables or even your actual data tables
您可以使用不同的模式,例如在两个数据库上执行以下操作:
然后您可以将该模式中的“重复”对象移动到一侧:
然后您可以使用 SQL Compare 等工具将 some.objects 移动到另一个数据库。将有两个名为 A 的对象,但它们将处于不同的模式中。当然,您的代码必须引用正确的架构。
但为什么它们必须位于同一个数据库中?您可以将它们保留为单独的数据库,并在一个数据库中使用同义词来指向另一个数据库中的对象,因此所有内容“看起来”都是本地的。如果 A 位于同一架构且位于同一数据库中,您打算如何从 A 进行查询?
您能准确解释一下您想要实现的目标吗?您是否正在尝试使生产数据库向后兼容,以便可以在不破坏现有应用程序的情况下推动开发更改?我认为将测试应用程序指向不同的数据库,然后将生产数据库完全更新(不像弗兰肯斯坦)会更干净。
You could use different schemas, e.g. on both databases do:
Then you can move the "duplicate" objects in that schema on one side:
Then you can just move the something.objects over to the other database using tools like SQL Compare etc. You'll have two objects called A, but they'll be in different schemas. Your code will have to reference the correct schema, naturally.
But why do they have to be in the same database? You can keep them as separate databases and use synonyms in one to point to the objects in the other, so everything "looks" local. How do you plan to query from A if they're both in the same schema and in the same database?
Could you explain exactly what you are trying to achieve? Are you trying to make your production database backward compatible, so that you can push your dev changes without breaking existing apps? I think it's much cleaner to just point your testing app at a different database, and then bring the production database up to date completely (not like Frankenstein).
您可以制作一个简单的 PHP 脚本来运行。
该脚本应该连接到第一个数据并将数据导入到第二个数据中
You can make an easy PHP script to run.
This script schould connect to the first data and import the data into the second one