Create a sample Table first Temp
Create an index on the Name field in a table
if exists (select name from sysindexes where name = " Span style= "color: #800000;" >suoyin " ) DROP INDEX Temp.suoyin -----< Span style= "color: #000000;" > When the index was created correctly, there was a problem with the query -(2 ) query index Span style= "color: #0000ff;" >select * from temp with (index=suoyin_name) where Name = a -- View index information for temp table Sp_helpindex temp
Grammar
CREATE [UNIQUE] [clustered| Nonclustered]
INDEX index_name on {table | view} (column [ASC | DESC] [,... N])
[With[pad_index][[,]fillfactor=fillfactor]
[[,]ignore_dup_key]
[[,]drop_existing]
[[,]statistics_norecompute]
[[,]sort_in_tempdb]
]
[ON filegroup]
The CREATE INDEX command creates indexes the parameters are described as follows: unique: Used to specify that a unique index is created for a table or view, that is, two rows with the same index value are not allowed. CLUSTERED: Used to specify that the index created is a clustered index. Nonclustered: Used to specify that the index created is a nonclustered index. Index_name: Used to specify the name of the index being created. Table: Specifies the name of the table on which the index is created. View: Specifies the name of the view that created the index. ASC| = fillfactor: Used to specify that the data for each index page is a percentage of the index page size when the index is created, and the value of FILLFACTOR is 1 to 100. Ignore_dup_key: Used to control the response of SQL Server when inserting duplicate data into a column that is contained in a unique clustered index. Drop_existing: Used to specify that a named pre-existing clustered index or nonclustered index should be dropped and recreated. Statistics_norecompute: Index statistics used to specify expiration are not automatically recalculated. SORT_IN_TEMPDB: Used to specify that intermediate sorting results are stored in the TEMPDB database when the index is created. ON filegroup: Used to specify the filegroup to hold the index.
SQL Server Index