What is the SQL index name for?

后端 未结 6 570
深忆病人
深忆病人 2021-01-04 10:58

In SQL, when I create a database index, I\'m required to give the index a name, as in

CREATE INDEX timestamp_index ON hit (timestamp);

The

6条回答
  •  醉梦人生
    2021-01-04 11:25

    Here are a couple of things to think about:

    How would you rebuild the index?

    How would you defragment/reorganize the index?

    how would you alter the index?

    How would you look at the index to see what columns are in it?

    When viewing an execution plan how would you know what index was used?

    How would you disable the index when doing BULK INSERT/BCP?

    How would you use the sys.dm_db_missing_index_details DMV when you don't know the name?

    BTW when you create a primary key a clustered index will be created by default, SQL Server will give it a name for you

    create table bla  (id int primary key)
    go
    
    select * from sys.sysobjects s 
    join sys.sysobjects s2 on s.parent_obj = s2.id
    where s2.name = 'bla'
    

    Here is the name that got generated for that index PK__bla__3213E83F66603565

提交回复
热议问题