Modify Unique Constraints

 

Applies To: SQL Server 2016

THIS TOPIC APPLIES TO: yesSQL Server (starting with 2016)yesAzure SQL DatabaseyesAzure SQL Data Warehouse yesParallel Data Warehouse

You can modify a unique constraint in SQL Server 2016 by using SQL Server Management Studio or Transact-SQL.

In This Topic

Security

Permissions

Requires ALTER permission on the table.

To modify a unique constraint

  1. In the Object Explorer, right-click the table containing the unique constraint and select Design.

  2. On the Table Designer menu, click Indexes/Keys….

  3. In the Indexes/Keys dialog box, under Selected Primary/Unique Key or Index, select the constraint you wish to edit.

  4. Complete an action from the following table:

    ToFollow these steps
    Change the columns that the constraint is associated with1) In the grid under (General), click Columns and then click the ellipses (…) to the right of the property.

    2) In the Index Columns dialog box, specify the new column or sort order or both for the index.
    Rename the constraintIn the grid under Identity, 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 optionIn the grid under Table Designer, select 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 in this table, you must clear this setting on the original index.
    Define a fill factorIn the grid under Table Designer, expand the Fill Specification category and type an integer from 0 to 100 in the Fill Factor box.
  5. On the File menu, click Savetable name.

To modify a UNIQUE constraint using Transact-SQL, you must first delete the existing UNIQUE constraint and then re-create it with the new definition. For more information, see Delete Unique Constraints and Create Unique Constraints.

Community Additions

ADD
Show: