Common SQL statements of SQL Server

Source: Internet
Author: User

Add foreign key constraints

Alter table dbo. account_userrole add foreign key (userid)
References DBO. account_user (userid)

Delete Index

Drop index [user_publish_ischeck] on [DBO]. [user_publish]

Delete primary key

Alter table user_publish drop constraint pk_user_publish

Create an index
Create nonclustered index [user_publish_ischeck] on [DBO]. [user_publish]
(
[Ischeck] ASC
)

-- Create a non-clustered Index

Create nonclustered index inx_entry_stock_on entry_stock_d (entry_stock_bi)

-- Primary key and non-Clustering
Alter table entry_stock_d add primary key nonclustered -- primary key and non-clustered
(
Entry_stock_bi, aid

}

Create a unique non-clustered Index

 
Create unique index ak_unitmeasure_name
On production. unitmeasure (name );
Go

Create a partition clustered Index

Create clustered index pk_user_publish_reftime
On user_publish (reftime)
On reftimeps (reftime );

Delete Constraints
Alter table [user_publish] Drop constraint df_user_publish_ischeck

Add Constraints
Alter table user_publish
Add constraint df_user_publish_ischeck default (0) for ischeck

Modify column type
Alter table user_publish alter column ischeck char (1) null

Delete Index

Drop index [user_publish_ischeck] on [DBO]. [user_publish]

Delete primary key

Alter table user_publish drop constraint pk_user_publish

Create an index
Create nonclustered index [user_publish_ischeck] on [DBO]. [user_publish]
(
[Ischeck] ASC
)

-- Create a non-clustered Index

Create nonclustered index inx_entry_stock_on entry_stock_d (entry_stock_bi)

-- Primary key and non-Clustering
Alter table entry_stock_d add primary key nonclustered -- primary key and non-clustered
(
Entry_stock_bi, aid

}

Create a unique non-clustered Index

 
Create unique index ak_unitmeasure_name
On production. unitmeasure (name );
Go

Create a partition clustered Index

Create clustered index pk_user_publish_reftime
On user_publish (reftime)
On reftimeps (reftime );

Delete Constraints
Alter table [user_publish] Drop constraint df_user_publish_ischeck

Add Constraints
Alter table user_publish
Add constraint df_user_publish_ischeck default (0) for ischeck

Modify column type
Alter table user_publish alter column ischeck char (1) null

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.