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

The method of selecting the mysql field type

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

I don't know if you have any knowledge about similar methods of selecting mysql field types before, but I'm here to tell you a little bit about it today. If you are interested, let's take a look at the body. I'm sure you'll get something after reading the method of choosing the type of mysql field.

Take up as little storage space as possible

Time type (choose the exact type) Type meaning time () hours, seconds, datetime () year, month, day, hour, second, year, year () year, month, day, year, date () year, month, day, timestamp () timestamp (1970-1-1 to the number of seconds experienced now) data integration preferably fixed length char (number of characters)

Fixed length, fast running speed, taking up more storage

Length: 255 character limit

Varchar (number of bytes)

The length is not fixed, and the content is relatively small, which requires part operation. This type should retain the length of 1-2 bytes to save the current data.

Length: 65535 byte limit

Store Chinese characters, such as character set utf8 (each Chinese character occupies 3 bytes), up to 65535prime 3-2 bytes

The time information best stored as an integer can be stored as an integer (timestamp) set collection type: set ('basketball', 'football', 'baseball', 'table tennis'); enum enumeration type: enum ('male', 'female', 'secret'); it is recommended to use set and enum types, which will be calculated and run through integer information parameters. Ip addresses can also be stored as integer information (there is an algorithm within mysql to change ip into numbers): mysql: inet_aton (ip) inet_ntoa (numeric) php: ip2long (ip) long2ip (numeric) summary:

The principle of field type selection: small footprint, fixed data length and integer data content.

After reading this article on the method of selecting mysql field types, what do you think? If you want to know more about it, you can continue to follow our industry information section.

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