name of index need to be unique in database?
Do index names hav开发者_如何学Pythone to be unique accross the entire sql server database, or just for that table?
For example, should I name my index: IX_OrderLoadCarrierDelivery_OrderLoadID
for the OrderLoadID
column of the OrderLoadCarrierDelivery
table. Or should I just name it IX_OrderLoadID
Thanks!
They have to be unique for the table or view they were created for.
Here is a reference on msdn that details this.
FTA:
index_name
Is the name of the index. Index names must be unique within a table or view but do not have to be unique within a database. Index names must follow the rules of identifiers.
I believe the convention is
IX_FieldName
No, per table.
That is, a unique (object_id, name) column pair in sys.indexes rather then just (name) in sys.objects (ignoring schema_id)
I'd also use something like IX_SingleColumn
or IX_ParentTable
. Adding table is superfluous unlike a default or check constraint, say, that is unique per DB
They have to be unique as everything gets stored in sysobjects with the name as key If you use SQL management studio, it's IX_Table_Field syntax
精彩评论