<HTML ><HEAD ><TITLE >Creating the Operator Class</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.73 "><LINK REV="MADE" HREF="mailto:pgsql-docs@postgresql.org"><LINK REL="HOME" TITLE="PostgreSQL 7.3.2 Documentation" HREF="index.html"><LINK REL="UP" TITLE="Interfacing Extensions To Indexes" HREF="xindex.html"><LINK REL="PREVIOUS" TITLE="Creating the Operators and Support Routines" HREF="xindex-operators.html"><LINK REL="NEXT" TITLE="Special Features of Operator Classes" HREF="xindex-opclass-features.html"><LINK REL="STYLESHEET" TYPE="text/css" HREF="stylesheet.css"><META NAME="creation" CONTENT="2003-02-03T20:17:34"></HEAD ><BODY CLASS="SECT1" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PostgreSQL 7.3.2 Documentation</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="xindex-operators.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Chapter 14. Interfacing Extensions To Indexes</TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="xindex-opclass-features.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="XINDEX-OPCLASS" >14.6. Creating the Operator Class</A ></H1 ><P > Now that we have the required operators and support routine, we can finally create the operator class: </P><PRE CLASS="PROGRAMLISTING" >CREATE OPERATOR CLASS complex_abs_ops DEFAULT FOR TYPE complex USING btree AS OPERATOR 1 < , OPERATOR 2 <= , OPERATOR 3 = , OPERATOR 4 >= , OPERATOR 5 > , FUNCTION 1 complex_abs_cmp(complex, complex);</PRE ><P> </P ><P > And we're done! (Whew.) It should now be possible to create and use B-tree indexes on <TT CLASS="TYPE" >complex</TT > columns. </P ><P > We could have written the operator entries more verbosely, as in </P><PRE CLASS="PROGRAMLISTING" > OPERATOR 1 < (complex, complex) ,</PRE ><P> but there is no need to do so when the operators take the same data type we are defining the operator class for. </P ><P > The above example assumes that you want to make this new operator class the default B-tree operator class for the <TT CLASS="TYPE" >complex</TT > data type. If you don't, just leave out the word <TT CLASS="LITERAL" >DEFAULT</TT >. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="xindex-operators.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="xindex-opclass-features.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Creating the Operators and Support Routines</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="xindex.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >Special Features of Operator Classes</TD ></TR ></TABLE ></DIV ></BODY ></HTML >