/ Published in: SQL
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).
MySQL has two built-in functions: INET_ATON() and INET_NTOA(). These two functions are used allover the place in any TCP/IP stack implementation or even application.
The INET_ATON() function converts Internet addresses from the numbers-and-dots notation into a 32-bit unsigned integer, and INET_NTOA() does the opposite.
MySQL has two built-in functions: INET_ATON() and INET_NTOA(). These two functions are used allover the place in any TCP/IP stack implementation or even application.
The INET_ATON() function converts Internet addresses from the numbers-and-dots notation into a 32-bit unsigned integer, and INET_NTOA() does the opposite.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
SELECT INET_ATON('192.168.0.10') AS ipn; SELECT INET_NTOA(3232235530) AS ipa; INSERT INTO tbl VALUES (..., INET_ATON('192.168.0.10'), ...);
URL: http://arjen-lentz.livejournal.com/44290.html