USING SCANN: obbligatorio. Il tipo di indice da utilizzare durante la creazione dell'indice
vettoriale. Questo algoritmo crea un indice
ScaNN.
SCANN è l'unico valore supportato. Non puoi modificare questo parametro.
QUANTIZER: facoltativo. Questo parametro mappa un vettore ad alta dimensionalità a una rappresentazione compressa. SQ8 è l'unico valore supportato. Non puoi
modificare questo parametro.
NUM_LEAVES: facoltativo. Specifica il numero di partizioni (foglie) da creare.
Modifica questa impostazione rispetto a quella predefinita solo se hai una buona
comprensione della ricerca ANN e del tuo set di dati. Il numero specificato non può essere
maggiore del numero di incorporamenti nella tabella di base.
DISTANCE_MEASURE: obbligatorio. Una formula matematica che calcola la
similarità di due vettori. Devi impostare la stessa unità di misura della distanza in questo
parametro della distanza nelle opzioni di ricerca approx_distance. I
laterali supportati sono:
L2_SQUARED
COSINE
DOT_PRODUCT
Esempio
L'esempio seguente mostra come creare un indice vettoriale nella tabella table_name
Aggiunge un indice vettoriale a una tabella esistente. Le ricerche vettoriali richiedono SCANN
come opzione di indice e il tipo di quantizzazione deve
essere SQ8.
USING SCANN: obbligatorio. Il tipo di indice da utilizzare durante la creazione dell'indice
vettoriale. Questo algoritmo crea un indice ScaNN.
SCANN è l'unico valore supportato. Non puoi modificare questo parametro.
QUANTIZER: facoltativo. Questo parametro mappa un vettore ad alta dimensionalità a una rappresentazione compressa. SQ8 è l'unico valore supportato. Non puoi
modificare questo parametro.
NUM_LEAVES: facoltativo. Specifica il numero di partizioni (foglie) da creare.
Modifica questa impostazione rispetto a quella predefinita solo se hai una buona
comprensione della ricerca ANN e del tuo set di dati. Il numero specificato non può essere
maggiore del numero di incorporamenti nella tabella di base.
DISTANCE_MEASURE: obbligatorio. Una formula matematica che calcola la
similarità di due vettori. Devi impostare la stessa unità di misura della distanza in questo
parametro della distanza nelle opzioni di ricerca approx_distance. I
laterali supportati sono:
L2_SQUARED
COSINE
DOT_PRODUCT
Esempio
L'esempio seguente mostra come aggiungere un indice vettoriale alla tabella t1.
[[["Facile da capire","easyToUnderstand","thumb-up"],["Il problema è stato risolto","solvedMyProblem","thumb-up"],["Altra","otherUp","thumb-up"]],[["Difficile da capire","hardToUnderstand","thumb-down"],["Informazioni o codice di esempio errati","incorrectInformationOrSampleCode","thumb-down"],["Mancano le informazioni o gli esempi di cui ho bisogno","missingTheInformationSamplesINeed","thumb-down"],["Problema di traduzione","translationIssue","thumb-down"],["Altra","otherDown","thumb-down"]],["Ultimo aggiornamento 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)."]]