Integer data type is one of the most commonly used data types.
1, INT (integer)
The storage range of INT (or INTEGER) data type is from -2 to the power of 3 1 (-2, 147,483,648) to the power of 2 to 3 1-/(2,147). Each INT type data is stored in 4 bytes, where 1 bit represents the sign of the integer value, and the other 3 1 bits represent the length and size of the integer value.
2、SMALLINT
The SMALLINT data type stores all positive and negative integers from -2 to15 (-32,768) to 2 to15-1(32,767). Each SMALLINT type of data occupies 2 bytes of storage space, where 1 bit represents the sign of the integer value, and 15 bit represents the length and size of the integer value.
3、TINYINT
TINYINT data type stores all positive integers from 0 to 255. Each data of type TINYINT occupies 1 byte of storage space.
4、BIGINT
BIGINT data type stores all data from-263 (-9,223,372,036,854,775,807) to 263-1(9,223,372,036,854,775,807). Each BIGINT type of data occupies 8 bytes of storage space.
Second, floating-point data types.
Floating point data types are used to store decimals. Data of floating-point values are stored in SQL Server by rounding. Rounding up means adding 1 to the value on the least significant bit of the reserved number when (and only if) the number to be rounded is non-zero, and making necessary rounding. If a number is rounded up, its absolute value will not decrease. For example, 3. 14 159265358979 is rounded by 2 digits and 12 digits respectively, and the results are 3. 14 1592653590.
1, real data type
Real data types can be accurate to the seventh decimal place, ranging from -3.40E -38 to 3.40E +38. Each real data occupies 4 bytes of storage space.
2. Floating
The data type of FLOAT can be accurate to15th place after the decimal point, ranging from-1.79E -308 to 1.79E +308. Each floating-point data occupies 8 bytes of storage space. The FLOAT data type can be written as FLOAT[ n]. N specifies the precision of floating-point data. N is an integer value between 1 and 15. When n takes 1 to 7, it actually defines a real number type of data, and the system stores it in 4 bytes; When n takes 8 to 15, the system thinks it is a floating-point number type and stores it in 8 bytes.
3, decimal system
DECIMAL data type can provide the actual storage space needed for decimals, but it also has some limitations. You can use 2 to 17 bytes to store values from-10 to 38-1 to 10. It can be written in decimal form [p [s]], and p and s determine the exact proportion and digits. Where p represents the total number of digits (excluding decimal point) of the value available for storage, and the default value is18; S represents the number of digits after the decimal point, and the default value is 0. For example, decimal (15 5) means that * * * has 15 bits, where the integer is 10 bits and the decimal is 5. Bittable 4-3 lists the relationship between the number of bytes required for each precision.
4. Numbers
The numeric data type is exactly the same as the decimal data type.
Note: In order to cooperate with the front-end development tools, SQL Server supports a maximum data precision of 28 bits by default.