SqlServer Basic Data Type

Source: Internet
Author: User
First Class: Integer Data bit: bit Data Type represents 0, 1 or NULL, that is, true, false. 1byte.int: 4 bytes are used to store positive and negative numbers. the storage range is-2 ^ 31 to 2 ^ 31-1.smallint. Positive and Negative values are stored in 2 bytes. storage range:-2 ^ 15 to 2 ^ 15-1tinyint: The smallest integer type, only 1 byte, range: 0 to this point ^ 8-1

First Class: Integer Data bit: bit Data Type represents 0, 1 or NULL, that is, true, false. occupies 1 byte. int: stores Positive and Negative Numbers in four bytes. the storage range is-2 ^ 31 to 2 ^ 31-1. smallint: stores positive and negative numbers in two bytes. storage range:-2 ^ 15 to 2 ^ 15-1 tinyint: The smallest integer type, only 1 byte, range: 0 so far ^ 8-1

Category 1: Integer Data

Bit: the bit data type is 0, 1 or NULL, which indicates true or false. 1 byte is occupied.
Int: 4 bytes to store positive and negative numbers. The storage range is-2 ^ 31 to 2 ^ 31-1.
Smallint: stores Positive and Negative Numbers in 2 bytes. The storage range is-2 ^ 15 to 2 ^ 15-1.
Tinyint: The smallest integer type. The value must be 1 byte. The value range is 0. ^ 8-1.


Second category: exact value data

Numeric: The number can reach 38 BITs. The number of bytes used for data storage varies with the number of used bits.
Decimal: similar to numeric


Category 3: Approximate floating point data

Float: Uses 8 bytes to store data. It can be up to 53 bits. The range is-1.79E + 308 to 1.79E + 308.
Real: the number of digits is 24. The value ranges from-3.04E + 38 to 3.04E + 38.


Category 4: Date and Time Data

Datatime: indicates that the time range can be from 1753/1/1 to 9999/12/31, and the time can be expressed as 3.33/1000 seconds. 8 bytes are used.
Smalldatetime: indicates that the time range can be from 1900/1/1 to 2079/12/31. Four bytes are used.


Category 5: String data

Char: The length is set. The shortest value is 1 byte and the maximum value is 8000 bytes. The insufficient length will be filled with blank space.
Varchar: The length is also set. The shortest value is 1 byte and the maximum value is 8000 bytes. The white space at the end is removed.
Text: the length and width are also set. up to 2 GB data can be stored.


Category 6: Unincode string data

Nchar: The length is set. The minimum value is 1 byte and the maximum value is 4000 bytes. The length is left blank. 2 bytes are required to store a character.
Nvarchar: Specifies the length. The minimum length is 1 byte and the maximum length is 4000 bytes. The white space at the end is removed. It takes 2 bytes to store a character.
Ntext: The length is set. The minimum value is 1 byte and the maximum value is 2 GB. The white space at the end is removed. It takes 2 bytes to store a character.

Category 7: currency data type

Money: The Record amount range is-92233720368577.5808 to 92233720368577. 5807. 8 bytes are required.
Smallmoney: The Record amount range is-214748.3648 to 214748. 36487. 4 bytes are required.


Category 8: Mark data

Timestamp: This data type is unique in each table! When a record in the table is changed, the timestamp field of the record is automatically updated. (Note: This value changes on the VM as long as any field in a row is modified. Or binary)
Uniqueidentifier: used to identify the unique record of many tables in the database.


Category 9: binary string data

Binary: a fixed-length binary string field. The minimum length is 1 and the maximum length is 8000.
Varbinary: When the tail of the data is 00, varbinary removes it.
Image: a variable-length binary string. The maximum length is 2 GB.

, Website space, server space
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.