SQL enhancements

Db2 12.1.2 includes new scalar functions that enhance the behavior and capability of SQL statements within Db2.

Attention: The Db2 12.1.2 release is currently available for the following Db2® products:
The following table displays SQL statement enhancements now available in Db2 12.1.2:
Table 1. SQL statement enhancements in 12.1.2
Enhancement Description
New numeric scalar function PI() The PI function returns the value of π 3.141592653589793. For more information, see PI scalar function.
New VECTOR data type The Db2 VECTOR data type allows you to store vector data from popular AI applications in Db2 12.1.2. In addition to storing vector data, Db2 can convert the data into a format that can be queried by using SQL statements. The supported coordinate types are INT8 and REAL/FLOAT32. For more information, see Vector values.
New VECTOR functions The following VECTOR functions allow you to store, convert, and work with vector data in Db2 12.1.2:
  • VECTOR: Constructs a vector from an input string
  • VECTOR_SERIALIZE: Converts a vector to a string
  • VECTOR_DISTANCE: Calculates the distance between two vectors using the specified metric
  • VECTOR_NORM: Calculates the distance between one vector and the zero vector using the specified metric
  • VECTOR_DIMENSION_COUNT: Returns the dimension of the vector type definition.
New scalar function VARCHAR_FORMAT_BINARY The VARCHAR_FORMAT_BINARY function returns a character string representation of a bit string that is formatted by using a format string.
New synonym scalar function ARRAY_MAX_CARDINALITY A synonym for the MAX_CARDINALITY function, the ARRAY_MAX_CARDINALITY scalar function returns a value of type BIGINT that represents the maximum number of elements that an array can contain.
New synonym scalar function HASHED_VALUE A synonym for the HASHEDVALUE function, the HASHED_VALUE scalar function returns the distribution map index of the row that is obtained by applying the partitioning function on the distribution key value of the row.