Problem
You are designing a database table for a web application that requires to store IP address of users who visits the site. The IP address is required to be stored a character data in the table. To define size of the character column you need to know maximum length of IP address. So, what is the maximum length of an IP address?
Solution
The IPv4 version of IP address is in the following format
255.255.255.255
To store IPv4 address we require 15 characters.
The IPv6 version of IP address is grouped into sets of 4 hex digits separated by colons, like the below
2001:0db8:85a3:0000:0000:8a2e:0370:7334
To store IPv6 address you require a 39 characters long column.
Conclusion
As IPv4 and IPv6 are the commonly use protocols, you better define a column with 39 characters length so that both the format address are saved in to the table without any issues.