Share via


How to: Modify Unique Constraints

Modify a unique constraint when you want to change the columns that the constraint is attached to, change the constraint name, or set additional properties for the constraint.

Note

Your computer might show different names or locations for some of the Visual Studio user interface elements in the following instructions. The Visual Studio edition that you have and the settings that you use determine these elements. For more information, see Visual Studio Settings.

To modify a unique constraint

  1. In your database diagram, right-click the table containing the constraint, then select Indexes/Keys from the shortcut menu.

    -or-

    Open the Table Designer for the table containing the constraint, right-click in the Table Designer, and choose Indexes/Keys from the shortcut menu.

  2. In the Indexes/Keys dialog box, under Selected Primary/Unique Key or Index, select the constraint you want.

  3. Complete an action from the following table:

    To

    Follow these steps

    Change the columns that the constraint is associated with

    In the grid, click Columns and then click the ellipses (…) to the right of the property.

    Rename the constraint

    Type a new name in the Name box. Make sure that your new name does not duplicate a name in the Selected Primary/Unique Key or Index list.

    Set the clustered option

    In the grid select the Create As Clustered and from the dropdown choose Yes to create a clustered index and No to create a non-clustered one. Only one clustered index can exist per table. If a clustered index already exists, you must first clear this setting on that index.

    Define a fill factor

    Expand the Fill Specification category and type an integer from 0 to 100 in the Fill factor box.

The constraint is updated in the database when you save your table or diagram.

See Also

Reference

Indexes/Keys Dialog Box

Other Resources

Working with Constraints

Working with Keys