如何在SQL Server CE(精简版)数据库中创建外键关系? [英] How do you create a foreign key relationship in a SQL Server CE (Compact Edition) Database?

查看:144
本文介绍了如何在SQL Server CE(精简版)数据库中创建外键关系?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Visual Studio 2005不提供用于在SQL Server CE数据库中创建表之间的关系的接口(我使用的是3.0版本),而且据我所知,您无法使用Management Studio打开Compact Edition数据库。任何想法?

解决方案

不幸的是,目前没有设计师支持(不像SQL Server 2005) CE。要建立关系,您需要使用SQL命令,例如:

  ALTER TABLE Orders 
ADD CONSTRAINT FK_Customer_Order
FOREIGN KEY(CustomerId)参考客户(CustomerId)

如果您正在做CE开发,常见问题:



编辑:在Visual Studio 2008中,现在可以通过右键单击您的表格在GUI中执行。 >

Visual Studio 2005 doesn't provide an interface for creating relationships between tables in a SQL Server CE database (I'm using version 3.0) and you can't open a Compact Edition DB using Management Studio as far as I know. Any ideas?

解决方案

Unfortunately there is currently no designer support (unlike for SQL Server 2005) for building relationships between tables in SQL Server CE. To build relationships you need to use SQL commands such as:

ALTER TABLE Orders
ADD CONSTRAINT FK_Customer_Order
FOREIGN KEY (CustomerId) REFERENCES Customers(CustomerId)

If you are doing CE development, i would recomend this FAQ:

EDIT: In Visual Studio 2008 this is now possible to do in the GUI by right-clicking on your table.

这篇关于如何在SQL Server CE(精简版)数据库中创建外键关系?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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