MySQL Forums
Forum List  »  Newbie

Re: What data type should I use and what storage engine?
Posted by: Rick James
Date: March 30, 2009 07:27PM

Storage engine -- depends on a lot of things you have not mentioned.

For IPv4...
IP INT UNSIGNED NOT NULL
INDEX(IP)  -- or UNIQUE or PRIMARY KEY
INET_ATON()
INET_NTOA()
If you prefer, then VARBINARY(15) is suitable. Do not split it into pieces, there is no advantage. I say BINARY, not CHAR because you don't need any fancy collation. You would be using only "=", not ranges, etc.

If you need things like 111.222.111.222/28, you could store the 28 in a separate column as either a TINYINT or as a mask (again with INT UNSIGNED).

IPv6...
A guess: VARBINARY(63)

Options: ReplyQuote


Subject
Written By
Posted
Re: What data type should I use and what storage engine?
March 30, 2009 07:27PM


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.