PostgreSQL: Network Address Type – INET to IP Addresses (IPv4, IPv6)

PostgreSQL provides Network Address related data types for storing information like IP Addresses, Mac Addresses.

If you are planning to store the IP Address in PostgreSQL Database, you should declare the INET data type for that column.
Internally, It checks the format of data so you cannot insert invalid format of data.

The input format for this type is address/y where address is an IPv4 or IPv6 address and y is the number of bits in the netmask.
If the /y portion is missing, the netmask is 32 for IPv4 and 128 for IPv6, so the value represents just a single host.

Small Demonstration:
Create a sample table:

Insert few sample Network related records:

Check the inserted data:


Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.

If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.

I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.

More from dbrnd.com

Leave a Reply

Be the First to Comment!

Notify of
avatar
wpDiscuz