Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What type of sqlserver decimal field is set (sqlserver character data types mainly include)
What type of sqlserver decimal field is set (sqlserver character data types mainly include)
In SQLServer, there are actually only two data types of decimal values: float and decimal, which are approximate values and exact values respectively.

Float means approximate value, which has a loss of accuracy. The data type is float(n), and n is optional. The default type is float(53), which takes 8 bytes. Although the value range of n is 1-53, in fact, float can only represent two types of float(53) and float(24), occupying 8 bytes and 4 bytes respectively.

Decimals have no precision loss. The data type decimal(p, s) needs to specify the maximum number of digits (p) and the decimal number (s) respectively. The maximum precision of the decimal data type is 38. In other words, the decimal data type can store up to 38 digits, and all digits can be located after the decimal point. The decimal data type stores accurate numerical representations, with no approximations.

Extended data:

Doubleprecision data type is equivalent to float(53), real is equivalent to float(24), and numeric is synonymous with decimal. We should avoid using doubleprecision, real and numeric directly in the program, but use float(24), float(53) and decimal.

Float is approximate and lacks precision; Decimal is an accurate value without loss of precision. When numerical values do not allow loss of precision, decimal data types are used to store data. When calculating the division of decimals, SQLServer implicitly upgrades the data type and converts it into float(24) or float(53) according to the data type of decimal values.