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

Home -> Community -> Usenet -> c.d.o.misc -> Re: IP data type

Re: IP data type

From: Albert Godfrind <agodfrin_at_fr.oracle.com>
Date: Wed, 02 Jun 1999 10:51:52 +0200
Message-ID: <3754F0A8.78FE919@fr.oracle.com>


Sam Petitto wrote:

> I've been asked to create a field to hold IP addresses. The request
> is for
> data type INTEGER with length at least 32 bits. I don't think INTEGER
> is
> the proper data type to use because an IP address have several
> "periods"
> in it (xxx.xxx.x.xxx). Shouldn't I use the VARCHAR2 data type ?

Well, an IP adress is really a 32-bit number. The 'dot' notation (for example: 140.86.120.250) lists each byte in that number as a separate decimal number.

So, storing an IP address as a number really means storing a value (for the above example) like: (((140*256) + 86) *256 + 120) * 256 + 250.

What is your goal in storing IP adresses ? Will you search on them ? Do you plan on doing any wildcard searches (like get all hosts with adresses like 140.86.*.* ?). Do you plan to exchange binary addresses with other systems or use them for direct adressing of nodes ?

If you plan on doing wildcard searches, you may want to break addresses down into individual bytes. If you intend to use binary IP addresses directly, you may also need to think about subtle issues like byte ordering or endian-ness ?

I guess you may as well think about compatibility with the larger IPv6 addresses.

/albert

--

Albert Godfrind         Oracle Data Server Division
Oracle Corporation      Multimedia and GeoSpatial Technologies
C.I.C.A                 Email:  agodfrin_at_fr.oracle.com
2229 Route des Crêtes   Phone:  +33/4/92.94.21.37
06560 Sophia-Antipolis  Mobile: +33/6/09.97.27.23
France                  FAX:    +33/4/92.94.21.45
                        http://www.oracle.com




Received on Wed Jun 02 1999 - 03:51:52 CDT

Original text of this message

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