SQL Server Index

Source: Internet
Author: User
Tags filegroup

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.