title: How to store a 128 bit number in a single column in MySQL?
body: <p>I'm changing some tables to store IP addresses as numbers rather than strings.  This is simple with IPv4 where the 32 bit address can fit into an integer column.  However, an IPv6 address is 128 bits.</p>
  
  <p>The <a href="http://dev.mysql.com/doc/refman/5.1/en/numeric-types.html" rel="noreferrer">MySQL documentation</a> only shows numeric types up to 64 bits ("bigint").</p>
  
  <p>Should I stick with char/varchar for IPv6? (Ideally I'd like to use the same column for IPv4 and IPv6, so I'd prefer not to do this).</p>
  
  <p>Is there anything better than using two bigint columns?  I would prefer not to have to break the value into upper and lower /64 whenever using the address.</p>
  
  <p>I'm using MariaDB 5.1 - if there's a better solution in a later version of MySQL then that would be nice to know, although not helpfully immediately.</p>
  
  <p><strong>[EDIT]</strong> Note that I'm after a recommendation for the <em>best</em> way to do this - it's obvious that there are various ways of doing this (including the existing string representation), but which is (in terms of performance) best?  (i.e. if someone has done the analysis already, that would save me doing it, or if I'm missing something obvious, that would be great to know too).</p>