How to Convert Binary (16bytes) to IP String

Moderator: NorbertKrupa

Post Reply
lazybones
Newbie
Newbie
Posts: 1
Joined: Fri Jul 12, 2013 11:07 am

How to Convert Binary (16bytes) to IP String

Post by lazybones » Thu Feb 20, 2014 8:55 am

We have stored IP address as Binary String. Could please tell me how to convert binary to IP String(xxx.xx.xx.xxx)?

id10t
GURU
GURU
Posts: 732
Joined: Mon Apr 16, 2012 2:44 pm

Re: How to Convert Binary (16bytes) to IP String

Post by id10t » Thu Feb 20, 2014 1:29 pm

Hi!

[DELETED]
Last edited by id10t on Fri May 08, 2015 4:38 pm, edited 1 time in total.

NorbertKrupa
GURU
GURU
Posts: 527
Joined: Tue Oct 22, 2013 9:36 pm
Location: Chicago, IL
Contact:

Re: How to Convert Binary (16bytes) to IP String

Post by NorbertKrupa » Thu Feb 20, 2014 2:39 pm

As @sKwa suggests, we need to see an example of how you're storing the it.

For example 192.168.1.1 in expressed as 11000000101010000000000100000001 in binary with an octet length of 32.

If you're using an IPv6 address, Vertica has built in functions to convert to/from binary:
  • V6_ATON - Converts an IPv6 address represented as a character string to a binary string.
  • V6_NTOA - Converts an IPv6 address represented as varbinary to a character string.
Checkout vertica.tips for more Vertica resources.

Post Reply

Return to “Vertica SQL”