<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>btree_gist &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/btree_gist/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Sat, 20 Aug 2016 13:05:07 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>PostgreSQL: ERROR &#8211; data type character varying has no default operator class for access method &#8220;gist&#8221;</title>
		<link>https://www.dbrnd.com/2016/08/postgresql-error-data-type-character-varying-has-no-default-operator-class-for-access-method-gist-btree_gist-extenstion-range-data-type/</link>
					<comments>https://www.dbrnd.com/2016/08/postgresql-error-data-type-character-varying-has-no-default-operator-class-for-access-method-gist-btree_gist-extenstion-range-data-type/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 20 Aug 2016 13:05:07 +0000</pubDate>
				<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[btree_gist]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[gist]]></category>
		<category><![CDATA[plpgsql]]></category>
		<category><![CDATA[Postgres Query]]></category>
		<category><![CDATA[postgresql]]></category>
		<category><![CDATA[PostgreSQL Administrator]]></category>
		<category><![CDATA[PostgreSQL Error]]></category>
		<category><![CDATA[PostgreSQL Programming]]></category>
		<category><![CDATA[PostgreSQL Tips and Tricks]]></category>
		<category><![CDATA[RANGE Datatype]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=3534</guid>

					<description><![CDATA[If we want to store range of data, we have very good options RANGE DATATYPE in PostgreSQL. PostgreSQL: Example of RANGE Data Type In one of our reporting servers, require to store a range of date bases on unique log code. Means, one unique code cannot be duplicated with the same range of dates. We [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F08%2Fpostgresql-error-data-type-character-varying-has-no-default-operator-class-for-access-method-gist-btree_gist-extenstion-range-data-type%2F&amp;linkname=PostgreSQL%3A%20ERROR%20%E2%80%93%20data%20type%20character%20varying%20has%20no%20default%20operator%20class%20for%20access%20method%20%E2%80%9Cgist%E2%80%9D" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F08%2Fpostgresql-error-data-type-character-varying-has-no-default-operator-class-for-access-method-gist-btree_gist-extenstion-range-data-type%2F&amp;linkname=PostgreSQL%3A%20ERROR%20%E2%80%93%20data%20type%20character%20varying%20has%20no%20default%20operator%20class%20for%20access%20method%20%E2%80%9Cgist%E2%80%9D" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F08%2Fpostgresql-error-data-type-character-varying-has-no-default-operator-class-for-access-method-gist-btree_gist-extenstion-range-data-type%2F&amp;linkname=PostgreSQL%3A%20ERROR%20%E2%80%93%20data%20type%20character%20varying%20has%20no%20default%20operator%20class%20for%20access%20method%20%E2%80%9Cgist%E2%80%9D" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F08%2Fpostgresql-error-data-type-character-varying-has-no-default-operator-class-for-access-method-gist-btree_gist-extenstion-range-data-type%2F&amp;linkname=PostgreSQL%3A%20ERROR%20%E2%80%93%20data%20type%20character%20varying%20has%20no%20default%20operator%20class%20for%20access%20method%20%E2%80%9Cgist%E2%80%9D" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F08%2Fpostgresql-error-data-type-character-varying-has-no-default-operator-class-for-access-method-gist-btree_gist-extenstion-range-data-type%2F&amp;linkname=PostgreSQL%3A%20ERROR%20%E2%80%93%20data%20type%20character%20varying%20has%20no%20default%20operator%20class%20for%20access%20method%20%E2%80%9Cgist%E2%80%9D" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F08%2Fpostgresql-error-data-type-character-varying-has-no-default-operator-class-for-access-method-gist-btree_gist-extenstion-range-data-type%2F&amp;linkname=PostgreSQL%3A%20ERROR%20%E2%80%93%20data%20type%20character%20varying%20has%20no%20default%20operator%20class%20for%20access%20method%20%E2%80%9Cgist%E2%80%9D" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2016%2F08%2Fpostgresql-error-data-type-character-varying-has-no-default-operator-class-for-access-method-gist-btree_gist-extenstion-range-data-type%2F&#038;title=PostgreSQL%3A%20ERROR%20%E2%80%93%20data%20type%20character%20varying%20has%20no%20default%20operator%20class%20for%20access%20method%20%E2%80%9Cgist%E2%80%9D" data-a2a-url="https://www.dbrnd.com/2016/08/postgresql-error-data-type-character-varying-has-no-default-operator-class-for-access-method-gist-btree_gist-extenstion-range-data-type/" data-a2a-title="PostgreSQL: ERROR – data type character varying has no default operator class for access method “gist”"></a></p><p>If we want to store range of data, we have very good options RANGE DATATYPE in PostgreSQL.</p>
<blockquote class="wp-embedded-content" data-secret="Xlw3WgIaqE"><p><a href="https://www.dbrnd.com/2016/08/postgresql-example-of-range-data-type-int4range-tsrange-daterange/">PostgreSQL: Example of RANGE Data Type</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2016/08/postgresql-example-of-range-data-type-int4range-tsrange-daterange/embed/#?secret=Xlw3WgIaqE" data-secret="Xlw3WgIaqE" width="600" height="338" title="&#8220;PostgreSQL: Example of RANGE Data Type&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<blockquote><p>In one of our reporting servers, require to store a range of date bases on unique log code.<br />
Means, one unique code cannot be duplicated with the same range of dates.</p></blockquote>
<p>We can store a range of dates using TSRANGE DATATYPE, but I have to also add one constraint which checks the unique combination of value and range.</p>
<p>Here, I have taken an example of the Student table where the combination of Stud Name and Duration should be unique.<br />
<strong>Try to Create below Student table:</strong><br />
<pre class="crayon-plain-tag">CREATE TABLE tbl_Students
(
    StudID INTEGER
    ,StudName CHARACTER VARYING 
    ,Duration TSRANGE    
    ,EXCLUDE USING GIST (StudName WITH=, Duration WITH &amp;&amp;) 
);</pre>
While creating above table with EXCLUDE Range constraint,I was getting below error .<br />
<pre class="crayon-plain-tag">ERROR:  data type character varying has no default operator class for access method "gist"
HINT:  You must specify an operator class for the index or define a default operator class for the data</pre>
<strong>The solution is to create btree_gist EXTENSION.</strong><br />
<pre class="crayon-plain-tag">CREATE EXTENSION btree_gist;</pre>
<strong>Insert few valid sample records:</strong><br />
<pre class="crayon-plain-tag">INSERT INTO tbl_Students 
VALUES 
(1,'Anvesh','[2000-01-01, 2005-01-01)')
,(2,'Roy','[2001-01-01, 2006-01-01)')
,(3,'Eric','[2002-01-01, 2007-01-01)')
,(4,'Jenny','[2000-01-01, 2005-01-01)');</pre>
<strong>Try to Insert Same Student Name with same range:</strong><br />
<pre class="crayon-plain-tag">INSERT INTO tbl_Students 
VALUES 
(5,'Anvesh','[2000-01-01, 2005-01-01)');</pre>
You will get an error like, because we have added constraint like, no duplicate range with the same Student Name.<br />
<pre class="crayon-plain-tag">ERROR:  conflicting key value violates exclusion constraint "tbl_students_studname_duration_excl"</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2016/08/postgresql-error-data-type-character-varying-has-no-default-operator-class-for-access-method-gist-btree_gist-extenstion-range-data-type/feed/</wfw:commentRss>
			<slash:comments>4</slash:comments>
		
		
			</item>
	</channel>
</rss>
