In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
MySQL data types in the correct use of numeric types, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.
Whether in a pitifully small free space or a large e-commerce site, it is necessary to design a reasonable table structure and make full use of the space. This requires us to have a full understanding of the common MySQL data types in database systems. Next, I will write some of my thoughts and share them with you.
Numeric type of MySQL data type
According to my classification method, digital types are divided into three categories: integer class, decimal class and number class.
By "number class", I mean DECIMAL and NUMERIC, which are of the same type. It is not strictly a numeric type because they actually store numbers as strings; each digit of his value (including the decimal point) takes up a byte of storage space, so this type consumes a lot of space. But one of its outstanding advantages is that the number of decimal places is fixed and will not be "distorted" in the operation, so it is more suitable for fields such as "price" and "amount" which do not require high precision but very high accuracy.
The decimal class, that is, the floating point type, has FLOAT and DOUBLE depending on the precision. Their advantage is accuracy. FLOAT can represent a decimal with an absolute value as small as about 1.17E-38 (0.000.0117 with 37 zeros after the decimal point), while DOUBLE can represent a decimal with an absolute value as small as about 2.22E-308 (0.000.0222 with 307 zeros after the decimal point).
The FLOAT type and DOUBLE type take up 4 bytes and 8 bytes of storage space, respectively. If you need to use decimal fields, precision requirements are not high, of course, use FLOAT. But to tell you the truth, how can our "civilian" data require such high accuracy? I haven't used these two types so far-- I haven't come across a suitable case for using them.
The ones that are most used and most worthy of careful calculation are the types of integers. From TINYINT, which takes up only one byte of storage space, to BIGINT, which takes up 8 bytes, choosing a type that is "sufficient" and takes up the least storage space should be considered when designing a database. TINYINT, SMALLINT, MEDIUMINT, INT, and BIGINT occupy 1 byte, 2 bytes, 3 bytes, 4 bytes and 8 bytes, respectively. For unsigned integers, the maximum integers that these types can represent are 255,65535, 16777215, 4294967295, and 18446744073709551615, respectively.
If it is used to save the age of the user (for example, the age saved in the database is not advisable), it is enough to use TINYINT; in the "vertical and horizontal" of Nine cities, the values of various skills, it is also enough to use SMALLINT; if you want to be used as an AUTO_INCREMENT IDENTIFY field of a table that will definitely not exceed 16000000 rows, of course, use MEDIUMINT instead of INT, just imagine, saving one byte per line, 16000000 rows can save more than 10 trillion.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.