[英]What types should I use for these data in MySQL?
I 'm not sure what type (set, integer, time, char, varchar, text,...) should I use for these data: 我不确定这些数据应使用哪种类型(集合,整数,时间,字符,varchar,文本等):
This depends a bit on your personal taste/your company's conventions, but I'd use: 这取决于您的个人品味/您公司的惯例,但是我会使用:
This is kinda funny question, but i will answer for IP address. 这是一个有趣的问题,但我会回答IP地址。
You could store IP address in an INT UNSIGNED. 您可以将IP地址存储在INT UNSIGNED中。
mysql> SELECT INET_ATON('192.168.0.10') AS ipn;
mysql> SELECT INET_NTOA(3232235530) AS ipa;
So you can store an IP address in an INT UNSIGNED (4 bytes) which is of course much more efficient and faster than a CHAR(15). 因此,您可以将IP地址存储在INT UNSIGNED(4字节)中,这当然比CHAR(15)更高效,更快。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.