开发者

SQL Server Index Naming Conventions [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

Is there some standard way to name indexes for SQL Server? It seems that the 开发者_Python百科primary key index is named PK_ and non-clustered indexes typically start with IX_. Are there any naming conventions beyond that for unique indexes?


I use

PK_ for primary keys

UK_ for unique keys

IX_ for non clustered non unique indexes

UX_ for unique indexes

All of my index name take the form of
<index or key type>_<table name>_<column 1>_<column 2>_<column n>


I usually name indexes by the name of the table and the columns they contain:

ix_tablename_col1_col2


Is it worth a special prefix for indices associated with foreign keys? I think so, since it reminds me that indices on foreign keys are not created by default, and so it is easier to see if they are missing.

For this, I am using names that match the name of the foreign key:

FK_[table]_[foreign_key_table]

or, where multiple foreign keys exist on the same table

FK_[table]_[foreign_key_table]_[foreign_key_field]


I know a old topic but thought I'd throw in my 2cents worth

  • PKC_ Primary Key, Clustered
  • PKNC_ Primary Key, Non Clusterd
  • NCAK_ Non Clustered, Unique
  • CAK_ Clustered, Unique
  • NC_ Non Clustered

Example;

NCAK_AccountHeader_OrganisationID_NextDate

Where NCAK : Non Clustered, Unique, AccountHeader : Table and OrganisationID_NextDate : Columns.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜