How do I index a database column

后端 未结 9 1853
难免孤独
难免孤独 2020-12-12 15:51

Hopefully, I can get answers for each database server.

For an outline of how indexing works check out: How does database indexing work?

9条回答
  •  温柔的废话
    2020-12-12 16:19

    Sql Server 2005 gives you the ability to specify a covering index. This is an index that includes data from other columns at the leaf level, so you don't have to go back to the table to get columns that aren't included in the index keys.

    create nonclustered index my_idx on my_table (my_col1 asc, my_col2 asc) include (my_col3);
    

    This is invaluable for a query that has my_col3 in the select list, and my_col1 and my_col2 in the where clause.

提交回复
热议问题