Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: modelling IPv6 as a number

Re: modelling IPv6 as a number

From: Maxim Demenko <mdemenko_at_gmail.com>
Date: Tue, 12 Dec 2006 23:06:47 +0100
Message-ID: <457F27F7.2060604@gmail.com>


Brian Peasland schrieb:
> maxwell.dana_at_gmail.com wrote:

>> Hi All,
>>
>> If I'm not mistaken, IPv6 requires 39 significant digits to represent
>> each possible IP as an integer. Oracle's maximum is  number(38). Has
>> anyone devised a scheme to store the integer value of IPv6 in oracle?
>>
>> Thanks
>>
>> Dana
>>

>
> Crazy question, but why model this as a number? The IPv6 addresses can
> look like the following:
>
> 2001:db8::1428:57ab
>
> The consecutive colons in the IPv6 address mean that zeros are all that
> is missing. So if you want to store this as a number, you'll have to
> change the given IPv6 address to the following:
>
> 2001:0db8:0000:1428:57ab
>
> Plus, you have to deal with hex values.
>
> Personally, I'd rather store the IPv6 address as a string. The only
> compelling reason I see to store as a number is to perform arithmetic on
> the value. Which I can't see a reason why I would do with an IP address...
>
> Cheers,
> Brian
>
>
>
>

I can well be wrong, but imho IP addresses are numbers, the usual dotted notation is commonly used mostly due to readability. I'm not sure as well whether it could be considered as a common task, but i've seen sometimes questions in OTN pl sql forum regarding calculation to which subnet belongs an particular IP address - which can be easily solved by ANDing of IP address with the subnet mask if both are represented as numbers (don't know whether the same arithmetic is still valid for IPv6).

On the other side, such task is probably far less common as simply store/retrieve the IP addresses to/from database, so varchar2 should be OK (and if the bitwise operations are required in the application, the plsql implementation should be not too complex).

Best regards

Maxim Received on Tue Dec 12 2006 - 16:06:47 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US