如何在SQL Server 2005中创建复合唯一约束
问题描述:
最好,我想知道如何使用SQL Server Management Studio界面来做到这一点,但这并不是完全必要的。如果只是有一个脚本可以在制作完表后添加一个脚本,那就没问题了。
Preferably I would like to know how to do it using the SQL Server Management Studio interface but that isn't completely necessary. If you simply have a script to add one after a table is made that would be fine.
答
在SQL Server Management Studio中
In SQL Server Management Studio
- 转到对象资源管理器
- 选择表并打开其设计器(不记得了它的内容在2005年被称为-修改表还是什么?)
- 在表设计器中,从工具栏(带有小键的表)中选择管理索引和键图标
- 在其中添加新索引并为其命名,单击其唯一设置
- goto the Object Explorer
- pick your table and open its designer (can't remember what it was called in 2005 - Modify Table or something?)
- in the table designer, pick the "Manage Indexes and Keys" icons from the toolbar (the table with the little key)
- in there, add a new index and give it a name, click it's "Unique" setting
- 打开索引定义中的列列表,然后添加列想要加入索引
就是这样! :)