来自不同数据库的表之间的关系 [英] Relationships between tables from different databases

查看:166
本文介绍了来自不同数据库的表之间的关系的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在SQL Server 2008中的不同数据库中定义表之间的关系?你能推荐一个在线教程来学习吗? (我喜欢ASP.NET,C#)

解决方案

不,你不能在数据库之间有外键。

数据完整性只在一个数据库内。如果您需要跨数据库的事务一致性,那么您应该使用单个数据库。主要问题是备份/恢复:恢复后,您的备份将不一致,因此您的备份会不一致。



最近的博客文章一个数据库或十个?更详细地解释



说,如果你需要这个,你可以使用触发器,并准备破坏数据


Is it possible to define relationships between tables in different databases in SQL server 2008? And can you recommend an online tutorial for studying it? (I prefer ASP.NET, C#)

解决方案

No, you can't have foreign keys between databases.

Data integrity is within a single database only. If you need transactional consistency across databases then you should use a single database. The main issue is backups/restores: you will end up with broken data after a restore because your backups are not consistent.

A recent blog article "One Database or Ten?" explains in more details

Saying that, you can use triggers if you need this and are prepared to have broken data

这篇关于来自不同数据库的表之间的关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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