MySQL Forums
Forum List  »  MyISAM

Re: Best Field Type for IP address?
Posted by: Me Me
Date: May 18, 2006 01:23PM


You could indeed store the IP addres in an INT UNSIGNED:

mysql> SELECT INET_ATON('') AS ipn;
| ipn |
| 3232235530 |

mysql> SELECT INET_NTOA(3232235530) AS ipa;
| 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). Naturally, you can call the function while you're inserting, so something like this is fine also:

INSERT INTO tbl VALUES (..., INET_ATON(''), ...)

Best Regards,

Dave Laurier

Options: ReplyQuote

Written By
October 12, 2005 12:19PM
October 17, 2005 01:37PM
Re: Best Field Type for IP address?
May 18, 2006 01:23PM
October 02, 2006 09:34AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.