Setting a non-primary key as a clustered index SQL Server Index Structure and usage (I) SQL Server Index Structure and usage (ii) SQL Server Index Structure and usage (III) SQL Server Index Structure and usage (4)

Source: Internet
Author: User

---- Set a non-primary key to clustered index [Step 4] to: http://king123654789.iteye.com/blog/1169191

1. View All indexes. Clustered indexes are created on the primary key by default.
Sp_helpindex person

2. -- delete the primary key constraint and remove the index constraint on the primary key queried in [1], for example, PK _ person _ 117F9D94. Remove the primary key constraint from the primary key field. This field is not the primary key.
Alter table person drop constraint PK _ person _ 117F9D94

3. -- create a clustered index to another column
Create clustered index test_index on person (date)

4.-If the original primary key field is changed to the primary key field, a non-clustered index is automatically created because the clustered index is already in place]
Alter table person add primary key (id)

 

SQL Server Index Structure and usage (I) SQL Server Index Structure and usage (ii) SQL Server Index Structure and usage (iii) SQL Server Index Structure and usage (IV)
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.