Create table statement

Source: Internet
Author: User

Let's take a look at the create table section of msdn. It's a long line of content that people don't know. It's a headache for me. The SQL script generated using SSMs is certainly functional, but it is always uncomfortable in terms of appearance. In addition, the scripts generated by SSMs, including foreign keys and constraints, are added by means of modification, and several lines are added for no reason.CodeIn fact, all the content is a create table.

If   Object_id ( ' Users ' , ' U ' ) Is   Not   Null   Drop   Table Users

Create   Table Users
(
Userid Uniqueidentifier   Not   Null
Primary   Key   Clustered (Userid ASC )
Default   Newid (),

Applicationid Uniqueidentifier   Not   Null
References Applications (applicationid ),

Email Varchar ( 255 ) Not   Null
Unique   Nonclustered (Applicationid ASC , Email ASC ),

Description Nvarchar ( 255 ) Null
)

This section contains some basic information, including: primary key, foreign key, clustered index, non-clustered index, non-null, allowed null, and default value. Both clustered indexes and non-clustered indexes allow multiple entries separated by commas. The drop statement contained in the SSMs generation script is too coorse, which is more concise and has the same functions.

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.