SQL Server index and constraint naming convention

enter image description here

SQL Server index naming convention

  • If Index is Primary Clustered Index: PK_TableName_PrimaryColumnName
  • If Index is Non-clustered Index: IX_TableName_ColumnName1_ColumnName2…
  • If Index is Unique Non-clustered Index: UX_TableName_ColumnName1_ColumnName2…

Constraint naming convention

  • FK_TableName_ForeignKeyColumnName for foreign key constraint
  • CK_TableName_DescriptiveNameForThisConstraint check constraint UQ_TableName_ColumnName - unique constraint, prefer to use unique index because of more options but if your intention is only for preventing duplicated data and not search, go for unique constraint.
  • DF_TableName_ColumnName default constraint

Credit https://blog.sqlauthority.com/2012/05/21/sql-server-renaming-index-index-naming-conventions/

Facebook Page