开发者

How can we set tables relations in SQL Server Express?

I have SQL Server Express 2008. How can I set 开发者_运维百科a table's relations in it?


Just like with any other database:

ALTER TABLE [tablename] 
ADD CONSTRAINT [foreign_key_name] 
FOREIGN KEY [local_column] 
REFERENCES [foreign_table] ([foreign_column]) 
ON UPDATE RESTRICT 
ON DELETE RESTRICT;

SQL Server Management Studio gives you a graphical UI to do the same thing through a click-and-point interface, but internally, it executes queries like these.


You could run the ALTER TABLE statements necessary to add the foreign key relationships between tables either via:

  • SQLCMD
  • Management Studio
    • 2008 Express download
    • 2005 Express download


You need to install SQL Server Management Studio or run the SQL to create the FKs yourself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜