Paste an article that explains the Data Type in SQL Server ..

Source: Internet
Author: User

Confusing Data Types in SQL Server

Author: ss_yingzi/blueidea Release Date: 10:49:03 |


(1)Char, varchar, text, nchar, nvarchar, ntext
Char
The length of a varchar is between 1 and 8000. The difference between them is that char is a fixed-length character data, and varchar is a variable-length character data. The so-called fixed length is fixed length, when the input
When the data length does not reach the specified length, it is automatically filled with spaces behind it to make the length reach the corresponding length, while the variable length data is not filled with spaces. Text stores variable-length non-
Unicode data. The maximum length is 2 ^ 31-1 (2,147,483,647) characters.

Compared with the preceding three data types, the names only contain letters "N", which indicate that the characters of the Unicode data type are stored. WrittenProgramFriends of Unicode should
This is a good idea. Only one byte is required for English characters, but there are many Chinese characters and two bytes are required for storage. It is easy to cause confusion when both English and Chinese characters exist. The Unicode Character Set is
Solved the incompatibility problem of character sets. All its characters are expressed in two bytes, that is, English characters are also expressed in two bytes. The length of nchar and nvarchar is from 1
In the range of 4000. Compared with Char and varchar, nchar and nvarchar can store a maximum of 4000 characters, whether in English or Chinese characters,
Varchar can store up to 8000 English letters and 4000 Chinese characters. We can see that when using the nchar and nvarchar data types, you do not have to worry about whether the entered characters are English or Chinese characters.
Convenience, but there is some loss in the amount of stored English hours.

(2)Datetime and smalldatetime
Datetime: Date and Time data from January 1, 3% to seconds.
Smalldatetime: Date and Time data from January 1, January 1-20, 1900 to January 1, June 6, accurate to minutes.

(3)Bitint, Int, smallint, tinyint, and bit
Bigint: integer data from-2 ^ 63 (-9223372036854775808) to 2 ^ 63-1 (9223372036854775807.
INT: integer data from-2 ^ 31 (-2,147,483,648) to 2 ^ 31-1 (2,147,483,647.
Smallint: integer data from-2 ^ 15 (-32,768) to 2 ^ 15-1 (32,767.
Tinyint: integer data from 0 to 255.
Bit: an integer of 1 or 0.

(4)Decimal and numeric
The two data types are equivalent. There are two parameters: P (precision) and S (number of decimal places ). P specifies the maximum number of decimal digits that can be stored on the left and right of the decimal point. P must be a value ranging from 1 to 38. S specifies the maximum number of decimal digits that can be stored on the right of the decimal point. s must be a value ranging from 0 to P. The default decimal place is 0.

(5)Float and real
Float: floating point data from-1.79 ^ 308 to 1.79 ^ 308.
Real: floating point data from-3.40 ^ 38 to 3.40 ^ 38. In SQL Server, the synonym for real is float (24 ).

ArticleSource: Western Network

------------------
OK. Here is how we search for SQL Server data on Google.
Type, because there is no information on hand, maybe many friends do not think this is important .. In addition, you can also understand the meaning of the word. There are not many materials on the Internet. I personally think that this is for your future database
It has a huge impact .. And it won't take you too much time. A good ype can make your database more perfect. Why not?

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.