Peter M. Groen wrote:
On Friday 11 November 2005 21:33, Cory @ SkyVantage wrote:
I'm using MySQL-Cluster 5.0, and we're doing some research.
What is everyone's opinion as to what the best fieldtype to store an IP
address in?
varchar(16) ? because 16 is the max chars of an ip address...
char(16) ?
text(16)
Not quite sure how to get the best memory utilization...
How about:
Field 1: First octet (int)
Field 2: Second octet (int)
Field 3: Third octet (int)
Field 4: Fourth octet (int)
Nah. One field, unsigned int type. Use the inet_aton and inet_ntoa
functions to convert the dotted decimal notation to and from a 4-byte
number.
That will stop you inserting invalid IP addresses like 192.168.329.243,
and it means you can do cool things like:
select ip from ip_table where ip between inet_aton("192.10.0.0") and
inet_aton("192.10.255.255")
Make sure you use an UNSIGNED INT column to store the number.
http://dev.mysql.com/doc/refman/5.0/en/miscellaneous-functions.html#id2720025
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]