Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

SqlServer series notes-data types

2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Data type description storage space

1. Character data type

Char (n) N is n bytes between 1 and 8000 characters

Nchar (n) N is 1 '4000 Unicode characters (2n bytes) + 2 bytes extra overhead

Ntext is up to 2301 (107741,823) Unicode characters 2 bytes per character

Nvarchar (max) is up to 230-1 (1073 741 823) Unicode characters 2 × characters + 2 bytes extra overhead

Text is a maximum of 231-1 (2147 483,647) characters of 1 byte per character

Varchar (n) N is 1 byte + 2 bytes extra overhead per character between 1 and 8000 characters.

Varchar (max) is a maximum of 231-1 (2147 483,647) characters with 1 byte + 2 byte extra overhead per character

two。 Exact numeric data type

Bit 0, 1, or Null1 bytes (8 bits)

Integer 1 byte between tinyint 0,0255and

Integer 2 bytes between smallint-32 768 and 32 767

Integer 4 bytes between int-2 147 483 648 2 147 483 647

Bigint-9 223 372 036 854 775 808 bytes of integers between 9 223 372 036 854 775 807

A maximum of 17 bytes between numeric (pforce s) or decimal (pforce s)-1 038 or 1 038 bytes

Money-922 337 203 685 477.580 8 '922 337 203 685 477.580 78 bytes

Smallmoney-214748.3648mm 2 14 748.36474 bytes

3. Approximate numerical data type

Float [(n)]-1.79 Ecolor 308 colors 2.23E lyrics 308 memorials 0pr 2.23E lyrics 308 colors 1.79 E stories 308N

< =24-4字节N>

24mura 8 bytes

Real-3.40Ecolor 38 words color 1.18Ely38 copyright 0magic 1.18Ely38 words 3.40Ecolor 384 bytes, synonym for real is float (24)

4. Binary data type

Binary (n) N is n bytes between 1 and 8000 hexadecimal digits

Image up to 231-1 (2147 483,647) hexadecimal digits 1 byte per character

Varbinary (n) N is 1 byte + 2 bytes extra overhead per character between 1 and 8000 hexadecimal digits

Varbinary (max) up to 231-1 (2147 483,647) hexadecimal digits 1 byte per character + 2 byte extra overhead

5. Date and time data type

Date 1 January to 31 December 9999 3 bytes

Datetime January 1, 1753 to December 31, 9999, accurate to the most recent 3.33 milliseconds 8 bytes

Datetime2 (n) N specified decimal seconds 6'8 bytes from January 1 to December 31, 9999

Datetimeoffset (n) N specified decimal seconds + /-offset of 8'10 bytes between January 1 and December 31, 1999.

SmalldateTime January 1, 1900 to June 6, 2079, accurate to 4 bytes per minute

Time (n) hours: minutes: seconds. 99999990Bytes N between the specified decimal seconds 3'5 bytes

6. Other system data types

Cursor contains a reference to the cursor and can be used only as a variable or stored procedure parameter is not applicable

Hierarchyid contains an extra overhead of 1 '892 bytes + 2 bytes for a reference to a location in the hierarchy

SQL_Variant may contain values of any system data type, except text, ntext, p_w_picpath, timestamp, xml, varchar (max), nvarchar (max), varbinary (max), sql_variant, and user-defined data types. The maximum size is 8000 bytes of data + 16 bytes (or metadata) 8016 bytes

Table is used to store datasets for further processing. The definition is similar to Create Table. Mainly used to return the result set of table-valued functions, they can also be used in stored procedures and batches depending on the number of rows defined and stored in the table

Timestamp orRowversion is a unique, automatically stored value for each table. Commonly used for version stamps, this value automatically changes 8 bytes when inserted and updated each time

The Uniqueidentifier can contain a globally unique identifier (Globally Unique Identifier,GUID). The guid value can be obtained from the Newid () function. The value returned by this function is unique to all computers. Although stored as a 16-bit binary value, it is displayed as char (36) 16 bytes

XML can store up to 2GB in Unicode or non-Unicode form

7. You can also customize the data type.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report