All Products
Search
Document Center

AnalyticDB:Create a vector table

Last Updated:Mar 28, 2026

Vector tables in AnalyticDB for PostgreSQL use the same CREATE TABLE syntax as heap tables. The vector column stores embeddings as an array and supports three data types. The syntax is fully compatible with SQL:1999 and partially compatible with SQL:2003.

Prerequisites

Before you begin, ensure that you have:

Syntax

CREATE TABLE [TABLE_NAME]
(
    C1 DATATYPE,
    C2 DATATYPE,
    ......,
    CN VECTORTYPE,
    PRIMARY KEY (one or more columns)
) DISTRIBUTED BY (C1);

VECTORTYPE is a placeholder for the vector column data type. The vector column supports the following types: SMALLINT[], FLOAT2[], and REAL(FLOAT4)[]. A table can have multiple vector columns.

Example

The following example creates a table named FACE_TABLE that stores face recognition embeddings alongside metadata:

CREATE TABLE FACE_TABLE (
    C1 INT,
    C2 REAL[] NOT NULL,
    C3 TIMESTAMP NOT NULL,
    C4 VARCHAR(20) NOT NULL,
    PRIMARY KEY (C1)
) DISTRIBUTED BY (C1);
ColumnTypeDescription
C1INTPrimary key and distribution key
C2REAL[]Vector column storing face embeddings
C3TIMESTAMPTimestamp column
C4VARCHAR(20)Label or metadata string associated with the embedding

Next steps

After creating a vector table, create a vector index to enable fast similarity search.