Operator-class functions on built-in data types

The database server provides the default operator class for the built-in secondary-access method, the generic B-tree. These operator-class functions handle the built-in data types. You can write new operator-class functions that operate on built-in data types if you want to do the following:
  • Extend the default operator class for the generic B-tree to redefine the ordering scheme that these operators support.

    The compare() function implements the ordering scheme for a B-tree index. The strategy functions (greaterthan(), lessthan(), and so on) let the query optimizer use the index for optimizing SQL statements. If you define a compare() function, you must also define the greaterthan(), lessthan(), or other functions that use the compare function.

    Because of routine overloading, these functions can have the same name as the functions in the default operator class. For more information, refer to Routine overloading.

  • Define a new operator class to provide an entirely new set of operators that operate on the built-in data type.

    You write operator-class functions with names that are different from any existing operating-class functions associated with the secondary-access method. You then register a new operator class that contains these new operators. The query optimizer can choose an index on this data type when the index uses this new operator class and the SQL statement contains one of the operators in this operator class.