Updated on 2024-06-03 GMT+08:00

Vector Data Types

Vector data types include floatvector and boolvector.

  • The floatvector data type indicates that multidimensional data contains data of the float type, for example, [1.0,3.0,11.0,110.0,62.0,22.0,4.0].
    • The floatvector member supports only single precision. Single-precision range: -3.402E+38 to +3.402E+38, 6-digit decimal digits.
    • The floatvector does not support NULL, Nan, or Inf as elements. If a vector contains NULL values, the database reports an error.
    • The floatvector cannot be NULL. The database reports an error when a NULL value is inserted, updated, or converted as vector data.
  • The boolvector data type indicates that the multidimensional data contains data of the Boolean type, for example, [0,0,0,0,0,1,0,0,1,0,0,0].
    • Members of the boolvector data type can express Boolean data in t(T)/f(F), y(Y)/n(N), 1/0, true/false, yes/no, or on/off mode.
    • The boolvector does not support NULL, Nan, or Inf as elements. If a vector contains NULL values, the database reports an error.
    • The boolvector cannot be NULL. The database reports an error when a NULL value is inserted, updated, or converted as vector data.

Usage of Vector Types

An example of using the vector type is as follows:
-- Create a table that contains vector types and set data dimensions. Dimensions must be specified for vector types during table creation.
gaussdb=# CREATE TABLE t1(id int unique, repr floatvector(4));
gaussdb=# CREATE TABLE t2(id int unique, repr boolvector(3));
-- Insert data.
gaussdb=# INSERT INTO t1 VALUES(0, '[30,12,12,25]');
gaussdb=# INSERT INTO t2 VALUES(1, '[1, 0, 1]');