<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Postgresql on David Hamp-Gonsalves</title><link>https://davidhampgonsalves.com/tags/postgresql/</link><description>Recent content in Postgresql on David Hamp-Gonsalves</description><generator>Hugo -- gohugo.io</generator><language>en-US</language><lastBuildDate>Tue, 18 Mar 2014 00:00:00 +0000</lastBuildDate><atom:link href="https://davidhampgonsalves.com/tags/postgresql/index.xml" rel="self" type="application/rss+xml"/><item><title>Postgresql Range Basics</title><link>https://davidhampgonsalves.com/postgresql-range-basics/</link><pubDate>Tue, 18 Mar 2014 00:00:00 +0000</pubDate><guid>https://davidhampgonsalves.com/postgresql-range-basics/</guid><description>In postgres 9.2 a new family of data types were added called Ranges. This is a quick overview of how to use them.
Range Types There are a handful of built in range types that cover the expected number and date types and you can also define your own if you need something outside of that.
Basic Operations Defining Range - CREATE TABLE ranges (range int4range) Inserting Range - INSERT INTO ranges VALUES(&amp;rsquo;[1, 4]') Infinate Ranges - INSERT INTO ranges VALUES(&amp;rsquo;[4, infinity]') Check Range Membership - SELECT * FROM ranges where range @&amp;gt; 2 Get Range Bounds - SELECT lower(range), upper(range) FROM ranges Defining Ranges Values You can define inclusive ranges using [2,3] and exclusive ranges using (1,4).</description></item></channel></rss>