Skip to main content
In , a matrix is a fixed‑size, multi‑dimensional array of DOUBLE values. Many models and feature representations are naturally expressed as matrices, making them a core building block for in‑database machine learning. Matrices help you:
  • Store dense numeric features — Keep related numeric inputs together as a single matrix value instead of many scalar columns. This storage simplifies machine learning training and scoring queries.
  • Represent model internals and transformations — Learned weights, intermediate layers, and linear transformations are often matrix‑shaped. Keeping these as matrices in SQL lets more of the machine learning pipeline execute directly in Ocient.
  • Apply math and linear‑algebra style operations in SQL — Matrix functions and operators let you construct, inspect, and manipulate matrix values in the same queries that drive machine learning models and preprocessing steps.
For an overview of Ocient machine-learning capabilities, see Machine Learning in Ocient.

Matrix Usage

To define a matrix data type in SQL, use the syntax MATRIX[rows][columns], where the bracketed numbers specify the number of matrix rows and columns. Example This example creates a basic table matrix_example with a matrix column col_matrix that contains matrices with two rows and three columns.
SQL
Insert data for two matrices into the matrix column.
SQL
For more DDL examples that use matrices, see CREATE TABLE SQL Statement Examples. For details about working with matrix values, see Data Types.

Matrix Functions

In the examples, _R{} and _C{} are vector notation, meaning _R{ 1,2,3 } is a row vector with values 1, 2, and 3.

Matrix Operators

Operator Examples

Bibliography

Golub, Gene H., and Charles F. Van Loan. Matrix Computations. 3rd ed, Johns Hopkins University Press, 1996. Array Functions and Operators Math Functions and Operators Tuple Functions and Operators Data Types Data Types for Data Pipelines Query Ocient
Last modified on May 20, 2026