...

View Full Version : Resolved Optimum Data types



primefalcon
03-31-2009, 09:31 AM
Im curious as the best data type to store Ip addresses and browser useragents

Im thinking char 15 for ip's but not sure if there is some hidden pitfall there..... and not sure for the useragent maybe varchar 100 or something does anyone have any better idea's? or suggestions

Fou-Lu
03-31-2009, 10:07 AM
For IP I'd prepare for IPv6:
IPv6 - char(39)
IPv4 - varchar(15) / char(15)

Useragents are trickier I have to admit. I generally use 100 myself, so long as you ensure that its truncated before going in. If you notice its too small, increase the size alloted for the useragent

primefalcon
03-31-2009, 10:30 AM
Ahh thank you very much, that is exactly why I asked on here I forgot about IPv6 coming out, 39/15 if I plan on using one column to store both I might have to use varchar 39 then, unless I do some testing to see which is which and have 2 different column types which i wonder if that's worth it....

Fou-Lu
03-31-2009, 10:53 AM
NP.
Nope, I'd just go for the one. I'd make it up as a varchar(39) - the extra space will be no big deal for the time being.
I messed up on that first post, I'd make it a varchar, not a char, since IPv6 can ignore leading 0's. I don't know what this will look like when it comes in over apache, but I figure the varchar is the way to go.

primefalcon
03-31-2009, 10:59 AM
Thanks for the help again,I guess I'm set for this



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum