USING SCANN: wajib diisi. Jenis indeks yang akan digunakan saat membuat indeks
vektor. Algoritma ini membuat indeks
ScaNN.
SCANN adalah satu-satunya nilai yang didukung. Anda tidak dapat mengubah parameter ini.
QUANTIZER: opsional. Parameter ini memetakan vektor berdimensi tinggi ke representasi yang dikompresi. SQ8 adalah satu-satunya nilai yang didukung. Anda tidak dapat
mengubah parameter ini.
NUM_LEAVES: opsional. Menentukan jumlah partisi (daun) yang akan dibuat.
Ubah setelan ini dari setelan defaultnya hanya jika Anda memiliki pemahaman yang baik tentang penelusuran ANN dan set data Anda. Jumlah yang ditentukan tidak boleh lebih besar daripada jumlah sematan dalam tabel dasar.
DISTANCE_MEASURE: wajib diisi. Formula matematika yang menghitung
kemiripan dua vektor. Anda harus menetapkan ukuran jarak yang sama dalam parameter ini dengan jarak dalam opsi penelusuran approx_distance. Lateral yang didukung adalah:
L2_SQUARED
COSINE
DOT_PRODUCT
Contoh
Contoh berikut menunjukkan cara membuat indeks vektor pada tabel table_name
USING SCANN: wajib diisi. Jenis indeks yang akan digunakan saat membuat indeks
vektor. Algoritma ini membuat indeks
ScaNN.
SCANN adalah satu-satunya nilai yang didukung. Anda tidak dapat mengubah parameter ini.
QUANTIZER: opsional. Parameter ini memetakan vektor berdimensi tinggi ke representasi yang dikompresi. SQ8 adalah satu-satunya nilai yang didukung. Anda tidak dapat
mengubah parameter ini.
NUM_LEAVES: opsional. Menentukan jumlah partisi (daun) yang akan dibuat.
Ubah setelan ini dari setelan defaultnya hanya jika Anda memiliki pemahaman yang baik tentang penelusuran ANN dan set data Anda. Jumlah yang ditentukan tidak boleh lebih besar daripada jumlah sematan dalam tabel dasar.
DISTANCE_MEASURE: wajib diisi. Formula matematika yang menghitung
kemiripan dua vektor. Anda harus menetapkan ukuran jarak yang sama dalam parameter ini dengan jarak dalam opsi penelusuran approx_distance. Lateral yang didukung adalah:
L2_SQUARED
COSINE
DOT_PRODUCT
Contoh
Contoh berikut menunjukkan cara menambahkan indeks vektor pada tabel t1.
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 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)."]]