Modify a primary key if you want to change the column order, index name, clustered option, or fill factor.
- In the Database window, click Database Diagrams under Objects, click the database diagram you want to open, and then click Design on the Database window toolbar.
- In your database diagram, right-click the table whose primary key you want to modify, and choose Indexes/Keys from the shortcut menu.
- Select the primary key index from the Selected index list.
- Type a new name in the Index name box. Make sure that your new name does not duplicate a name in the Selected index list.
The primary key is updated in the database when you save your database diagram.
Modify a foreign key constraint
Modify the foreign key side of a relationship if you want to change which columns are related to columns in the primary key table.
- In the Database window, click Database Diagrams under Objects, click the database diagram you want to open, and then click Design on the Database window toolbar.
- In your database diagram, right-click the relationship corresponding to the foreign key you want to modify, and then choose Properties from the shortcut menu.
- Choose the Relationships tab.
- Select the relationship from the Selected relationship list.
- In the Foreign key table column, expand the list in the first row.
- Select a different table column from the list. The foreign key column must match the data type and size of the primary key column, with these exceptions:
- A char column or sysname column can relate to a varchar column.
- A binary column can relate to a varbinary column.
- A user-defined data type can relate to its base type.
Any changes you make to the relationship’s properties take effect as soon as you move outside the grid in the property pages. The constraint is updated in the database when you save your database diagram.
Note Modifying a relationship in a database diagram marks both of the related tables as modified. Consequently, each table will also be marked as modified in any other database diagrams in which it appears.
- In the Database window, click Database Diagrams under Objects, click the database diagram you want to open, and then click Design on the Database window toolbar.
- In your database diagram, right-click the table containing the constraint, then select Constraints from the shortcut menu.
- Select the constraint you want to change from the Selected constraint list.
- Type a new name in the Constraint name box.
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.
- In the Database window, click Database Diagrams under Objects, click the database diagram you want to open, and then click Design on the Database window toolbar.
- In your database diagram, right-click the table containing the constraint, then select Indexes/Keys from the shortcut menu.
- Select the constraint you want to change from the Selected index list.
- Type a new name in the Index name box. Make sure that your new name does not duplicate a name in the Selected index list.
The constraint is updated in the database when you save your database diagram.