Hello people, what data type should I use to store ip addresses in a mysql database.
i would use varchar(20)
or higher valued varchar() if 20 is not enough. but note that searching through, sorting, select distincts etc on varchars would be slow depending on how much data you got in it.
giving the number preceding 0's, taking the . out and storing it as a big number?
forgive laymen' terms.
the problem would be when I have to recombine the number. How would I know where I have to put in the "."?
that's the point of putting in the preceding zeros.
128.166.18.4 = 128 166 018 004 =128166018004
when you need to return it in a more readable format, just insert periods every three spaces, and remove preceeding zeros after the periods.