TT_HASH
The TT_HASH function returns the hash value of an expression or list of expressions. This value is the value that is used by a hash index.
SQL syntax
TT_HASH(Expression [,...])Parameters
TT_HASH has the parameter:
| Parameter | Description |
|---|---|
|
|
One or more expressions to be used to determine the hash value of the expression or list of expressions. |
Description
-
Each expression must have a known data type and must be non-nullable. The hash value of the expression depends on both the value of the expression and its type. For example,
TT_HASHof anTT_INTEGERwith value 25 may be different fromTT_HASHof aNUMBERorBINARY_DOUBLEwith value 25. If you specify a list of expressions, theTT_HASHresult depends on the order of the expressions in the list. -
Since constants and expressions that are not simple column references are subject to internal typing rules, over which applications have no control, the best way to ensure that
TT_HASHcomputes the desired value for expressions that are not simple column references is toCASTthe expression to the desired type. -
The result type of
TT_HASHisTT_INTEGERin 32-bit mode andTT_BIGINTin 64-bit mode. -
TT_HASHcan be used in a SQL statement anywhere an expression can be used. For example,TT_HASHcan be used in aSELECTlist, aWHEREorHAVINGclause, anORDER BYclause, or aGROUP BYclause. -
The output of error messages, trace messages, and
ttXactAdmindisplay the hash value as a signed decimal so that the value matchesTT_HASHoutput.
Examples
The following query finds the set of rows whose primary key columns hash to a given hash value:
SELECT * FROM t1 WHERE TT_HASH(pkey_col1, pkey_col2, pkey_col3) = 12345678;