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

What data type should be used for prices in mysql

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "what data type should be used for price in mysql". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "what data type should be used for price in mysql"!

In mysql, prices are of type "DECIMAL." Decimal is a data type specifically designed for finance-related problems. It is actually stored in the form of a string. The integer part and the decimal part can be delimited when defining it. When the precision requirement is relatively high (such as currency and scientific data), it is better to use DECIMAL type.

Operating environment of this tutorial: Windows 7 system, MySQL8 version, Dell G3 computer.

In mysql, prices are of type "DECIMAL."

Decimal is a data type specifically designed for finance-related problems. In MySQL, fixed points are stored in string form. When the precision requirement is high (such as currency and scientific data), it is better to use DECIMAL type.

Decimal is a data type of SQL Server, MySql and other databases. It does not belong to floating point number type. It can delimit the digits of integer part and decimal part when defining. Using exact decimal types not only ensures more accurate data calculations, but also saves storage space, such as decimal(4,2) for percentages. The range of stored data is: -10^38 to 10^38 -1 fixed precision and decimal digits. A decimal data takes 2 to 17 bytes.

Grammar:

decimal[ (p[ , s] )]

p (significant digits): The maximum number of decimal places that can be stored, both sides of the decimal point included. The significant digits must be a value between 1 and the maximum significant digit of 38. The default significant digit is 18.

s (decimal places): The maximum decimal number that can be stored to the right of the decimal point. The number of decimal places must be a value from 0 to p. The number of decimal places can be specified only if significant places are specified. The default decimal place is 0; therefore, 0

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