What type should I store IP addresses for MySQL?

前端 未结 3 907
遇见更好的自我
遇见更好的自我 2020-12-03 15:34

I was going to use varchar(20), but I was wondering what should if I should do INT and strip off the periods instead. What would be better and why?

3条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-03 16:10

    store IPV4 as int unsigned

    http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_inet-aton

    http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#function_inet-ntoa

提交回复
热议问题