USING SCANN : obligatoire. Type d'index à utiliser lors de la création de l'index vectoriel. Cet algorithme crée un index ScaNN.
SCANN est la seule valeur acceptée. Vous ne pouvez pas modifier ce paramètre.
QUANTIZER : facultatif. Ce paramètre mappe un vecteur de grande dimension à une représentation compressée. SQ8 est la seule valeur acceptée. Vous ne pouvez pas modifier ce paramètre.
NUM_LEAVES : facultatif. Indique le nombre de partitions (feuilles) à créer.
Ne modifiez ce paramètre par défaut que si vous comprenez bien la recherche ANN et votre ensemble de données. Le nombre spécifié ne peut pas être supérieur au nombre d'intégrations dans la table de base.
DISTANCE_MEASURE : obligatoire. Formule mathématique qui calcule la similarité de deux vecteurs. Vous devez définir la même mesure de distance dans ce paramètre que celle des options de recherche approx_distance. Les côtés acceptés sont les suivants :
L2_SQUARED
COSINE
DOT_PRODUCT
Exemple
L'exemple suivant montre comment créer un index vectoriel sur la table table_name.
Ajoute un index vectoriel à une table existante. Les recherches vectorielles nécessitent SCANN comme option d'index et le type de quantification doit être SQ8.
USING SCANN : obligatoire. Type d'index à utiliser lors de la création de l'index vectoriel. Cet algorithme crée un index ScaNN.
SCANN est la seule valeur acceptée. Vous ne pouvez pas modifier ce paramètre.
QUANTIZER : facultatif. Ce paramètre mappe un vecteur de grande dimension à une représentation compressée. SQ8 est la seule valeur acceptée. Vous ne pouvez pas modifier ce paramètre.
NUM_LEAVES : facultatif. Indique le nombre de partitions (feuilles) à créer.
Ne modifiez ce paramètre par défaut que si vous comprenez bien la recherche ANN et votre ensemble de données. Le nombre spécifié ne peut pas être supérieur au nombre d'intégrations dans la table de base.
DISTANCE_MEASURE : obligatoire. Formule mathématique qui calcule la similarité de deux vecteurs. Vous devez définir la même mesure de distance dans ce paramètre que celle des options de recherche approx_distance. Les côtés acceptés sont les suivants :
L2_SQUARED
COSINE
DOT_PRODUCT
Exemple
L'exemple suivant montre comment ajouter un index vectoriel à la table t1.
Sauf indication contraire, le contenu de cette page est régi par une licence Creative Commons Attribution 4.0, et les échantillons de code sont régis par une licence Apache 2.0. Pour en savoir plus, consultez les Règles du site Google Developers. Java est une marque déposée d'Oracle et/ou de ses sociétés affiliées.
Dernière mise à jour le 2025/09/04 (UTC).
[[["Facile à comprendre","easyToUnderstand","thumb-up"],["J'ai pu résoudre mon problème","solvedMyProblem","thumb-up"],["Autre","otherUp","thumb-up"]],[["Difficile à comprendre","hardToUnderstand","thumb-down"],["Informations ou exemple de code incorrects","incorrectInformationOrSampleCode","thumb-down"],["Il n'y a pas l'information/les exemples dont j'ai besoin","missingTheInformationSamplesINeed","thumb-down"],["Problème de traduction","translationIssue","thumb-down"],["Autre","otherDown","thumb-down"]],["Dernière mise à jour le 2025/09/04 (UTC)."],[],[],null,["# Cloud SQL Data Definition Language (DDL)\n\n\u003cbr /\u003e\n\nMySQL \\| PostgreSQL \\| SQL Server\n\n\u003cbr /\u003e\n\nThis page defines the syntax for Cloud SQL extensions to the MySQL data\ndefinition language (DDL) statements.\n\nVECTOR statements\n-----------------\n\nThis section has information about `VECTOR` statements.\n\n### CREATE VECTOR INDEX\n\nCreates a vector index. \n\n CREATE VECTOR INDEX index_name\n [opt_index_type]\n ON table_name (column_name)\n [index_options]\n\n where opt_index_type is:\n | USING SCANN\n\n where index_option is :\n USING SCANN\n | [QUANTIZER=SQ8]\n | [NUM_LEAVES=int_value]\n | DISTANCE_MEASURE=L2_SQUARED|DOT_PRODUCT|COSINE\n\n**Parameters**\n\n- **`USING SCANN`** : required. The index type to use when creating the vector index. This algorithm creates a [ScaNN\n index](https://research.google/blog/announcing-scann-efficient-vector-similarity-search/). `SCANN` is the only supported value. You can't modify this parameter.\n- **`QUANTIZER`** : optional. This parameter maps a high-dimensional vector to a compressed representation. `SQ8` is the only supported value. You can't modify this parameter.\n- **`NUM_LEAVES`**: optional. Specifies how many partitions (leaves) to build. Only change this setting from its default setting if you have a good understanding of ANN search and your dataset. The number specified can't be larger than the number of embeddings in the base table.\n- **`DISTANCE_MEASURE`** : required. A mathematical formula that calculates the similarity of two vectors. You must set the same distance measure in this parameter as the distance in the `approx_distance` search options. The supported laterals are:\n - `L2_SQUARED`\n - `COSINE`\n - `DOT_PRODUCT`\n\n**Example**\n\nThe following example shows how to create a vector index on the `table_name`\ntable \n\n CREATE\n VECTOR INDEX index1\n ON table_name(vector_column_name)\n USING SCANN QUANTIZER = SQ8 DISTANCE_MEASURE = l2_squared;\n\n### ALTER TABLE\n\nAdds a vector index to an existing table. Vector searches require `SCANN`\nas the index option and the quantization type must\nbe `SQ8`. \n\n ALTER TABLE table_name\n ADD VECTOR INDEX index_name(key_part)[index_option];\n\n WHERE key_part is:{ _col_name_[(_length_)] | (_expr_) }\n WHERE\n index_option\n is:USING\n SCANN\n | [QUANTIZER = SQ8]\n | [NUM_LEAVES = int_value]\n | DISTANCE_MEASURE\n = L2_SQUARED | DOT_PRODUCT | COSINE\n\n**Parameters**\n\n- **`USING SCANN`** : required. The index type to use when creating the vector index. This algorithm creates a [ScaNN\n index](https://research.google/blog/announcing-scann-efficient-vector-similarity-search/). `SCANN` is the only supported value. You can't modify this parameter.\n- **`QUANTIZER`** : optional. This parameter maps a high-dimensional vector to a compressed representation. `SQ8` is the only supported value. You can't modify this parameter.\n- **`NUM_LEAVES`**: optional. Specifies how many partitions (leaves) to build. Only change this setting from its default setting if you have a good understanding of ANN search and your dataset. The number specified can't be larger than the number of embeddings in the base table.\n- **`DISTANCE_MEASURE`** : required. A mathematical formula that calculates the similarity of two vectors. You must set the same distance measure in this parameter as the distance in the `approx_distance` search options. The supported laterals are:\n - `L2_SQUARED`\n - `COSINE`\n - `DOT_PRODUCT`\n\n**Example**\n\nThe following example shows how to add a vector index on the `t1` table. \n\n ALTER TABLE t1 ADD VECTOR INDEX index1(j)\n USING SCANN QUANTIZER = SQ8 DISTANCE_MEASURE = l2_squared;\n\nWhat's next\n-----------\n\n- Read the [overview about vector search on Cloud SQL](/sql/docs/mysql/vector-search).\n- Learn how to [enable and disable vector embeddings on your instance](/sql/docs/mysql/enable-vector-search).\n- Learn how to [generate vector embeddings](/sql/docs/mysql/generate-manage-vector-embeddings#generate_vector_embeddings_based_on_row_data).\n- Learn how to [create vector indexes](/sql/docs/mysql/create-manage-vector-indexes).\n- Learn how to [perform searches on vector embeddings](/sql/docs/mysql/search-filter-vector-embeddings)."]]