Network Operators

I l @ ve RuBoard

The network operators that are built into PostgreSQL are useful for making comparisons between IP addresses. These operators function on INET and CIDR data types equally.

Listing

<

Less than

<=

Less than or equal to

=

Equals

>=

Greater than or equal to

>

Greater than

<>

Not equal

<<

Contained within

<<=

Contained within or equals

>>

Contains

>>=

Contains or equals

Notes/Examples

Use the following to find all the IP addresses less than the one specified:

 SELECT * FROM computers WHERE ipaddr<'192.168.0.100' 

Similarly, use the following to find all the IP addresses on the given subnet:

 SELECT * FROM computers WHERE ipaddr<<'192.168.0.1/24' 
I l @ ve RuBoard


PostgreSQL Essential Reference
PostgreSQL Essential Reference
ISBN: 0735711216
EAN: 2147483647
Year: 2001
Pages: 118
Authors: Barry Stinson

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net