MSSQL SQL Server specification use method sharing

Source: Internet
Author: User
Tags mssql

Transferred from: http://www.maomao365.com/?p=5586

Summary:
The following focuses on SQL Server table design and scripting, related specifications

———————————
Data table field type selection:
Character type Select the appropriate varchar nvarchar type based on length
Recommended money type for the amount involved
Numeric decimal type is recommended with decimal digits
Custom identity columns suggest using the bigint type
Time Type Select Date datetime smalldatetime as required
Try to avoid using the XML text ntext image type
————————————–
Table Design
The table name of the same business module is set to have the same identity prefix
Column Design
Fields of the same function should have the same name and type definition in all tables
All columns prohibit null values
Table related Design
Table as far as possible to set a reasonable primary key, try to use single field primary key
Index Design:
The fields used to join the table, try to set the index
The columns involved in order by, as far as possible to set as index
Index include does not include too many columns
Don't have too many indexes on a single sheet

——— Scripting ————— –
In scripting, it is forbidden to perform complex calculations
In scripting, avoid using SELECT *: Reduce the number of queries and unnecessary returns
In scripting, it is forbidden to perform calculations on indexed columns
Use fewer cursors
Use fewer triggers
In scripting, the parameter types and column types in the table need to be consistent
scripting, avoid splicing SQL, using parametric processing
In scripting, minimize the number of join tables
In scripting, limit the number of in, because unreasonable in causes the "DB estimate execution plan" error.
Avoiding the use of large transactions can lead to deadlocks
Try to use UNION all to replace the Union combination table
In a script query, the data is returned as much as you want on page

MSSQL SQL Server specification use method sharing

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.