How do I index a database column

后端 未结 9 1875
难免孤独
难免孤独 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:09

    In SQL Server, you can do the following: (MSDN Link to full list of options.)

    CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name 
        ON  ( column [ ASC | DESC ] [ ,...n ] ) 
        [ INCLUDE ( column_name [ ,...n ] ) ]
        [ WHERE  ]
    
    
    

    (ignoring some more advanced options...)

    The name of each Index must be unique database wide.

    All indexes can have multiple columns, and each column can be ordered in whatever order you want.

    Clustered indexes are unique - one per table. They can't have INCLUDEd columns.

    Nonclustered indexes are not unique, and can have up to 999 per table. They can have included columns, and where clauses.

    提交回复
    热议问题