Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

name of index need to be unique in database?

Tags:

sql-server

Do index names have 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!

like image 999
BrokeMyLegBiking Avatar asked Nov 13 '09 21:11

BrokeMyLegBiking


People also ask

Do database indexes need unique?

If you feel like your data should be UNIQUE , use a unique index. You may think it's optional (for instance, working it out at application level) and that a normal index will do, but it actually represents a guarantee for Mysql that each row is unique, which incidentally provides a performance benefit.

Do we need index on unique key?

Unique indexes are indexes that help maintain data integrity by ensuring that no rows of data in a table have identical key values. When you create a unique index for an existing table with data, values in the columns or expressions that comprise the index key are checked for uniqueness.

Can indexes also be unique?

Explanation: Indexes can also be unique, like the UNIQUE constraint.

Is index a unique constraint?

There is no difference between Unique Index and Unique Constraint. Even though syntax are different the effect is the same. Unique Constraint creates Unique Index to maintain the constraint to prevent duplicate keys.


1 Answers

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 
like image 185
Joseph Avatar answered Sep 25 '22 14:09

Joseph