Partager via


How to: Rename Indexes

New indexes are automatically given system-defined names based on the database table name. If you create multiple indexes on a table, the index names are appended with "_1," "_2," and so on. You can rename an index as long as index names are unique within the table.

Note

A new version of Table Designer appears for databases in the SQL Server 2012 format. This topic describes the old version of Table Designer, which you use with databases in earlier formats of SQL Server.

In the new version, you can change a table definition through a graphical interface or directly in a script pane. If you use the graphical interface, the table’s definition is automatically updated in the script pane. To apply the SQL code in the script pane, choose the Update button. For more information about the new version, see How to: Create Database Objects Using Table Designer.

Note

When you create a primary key or unique constraint for a table, an index with the same name as the constraint is automatically created for the table. Because index names must be unique for a table, you cannot create or rename an index to have the same name as the primary key or unique constraint for the table.

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 Customizing Development Settings in Visual Studio.

To rename an index

  1. In Server Explorer, select the table with the index you want to rename.

  2. From the Database menu, click Open Table Definition.

  3. From the Table Designer menu, click Indexes/Keys.

  4. Select the index from the Selected Primary/Unique Key or Index list.

  5. In the grid, click Name and type a new name into the text box.

    Your changes are saved to the database when you save the table.

See Also

Other Resources

Working with Indexes