Tetap teratur dengan koleksi
Simpan dan kategorikan konten berdasarkan preferensi Anda.
Halaman ini memberikan ringkasan cara memigrasikan data ke dalam dan ke luar
AlloyDB untuk PostgreSQL.
Mengimpor data
Anda dapat memigrasikan data ke AlloyDB melalui dua metode:
Mengimpor file yang berisi data Anda secara manual.
Menggunakan Google Cloud Database Migration Service untuk memigrasikan konten seluruh instance PostgreSQL aktif ke cluster AlloyDB baru.
Mengimpor data yang diarsipkan dari file
AlloyDB memungkinkan Anda mengimpor data dari file yang berada di bucket Cloud Storage.
AlloyDB mendukung berbagai format file untuk impor data, termasuk yang berikut:
CSV, dengan konten satu tabel
per file, dimuat menggunakan psql.
DMP, arsip biner dari seluruh database PostgreSQL, yang diimpor menggunakan pg_restore.
SQL, rekonstruksi teks biasa dari database PostgreSQL, yang diproses dengan psql.
Memigrasikan instance aktif dengan Database Migration Service
Sebagai alternatif untuk mengimpor file dump data secara manual, Anda dapat menggunakan
Database Migration Service untuk AlloyDB.
Layanan ini memungkinkan Anda memigrasikan seluruh konten
instance PostgreSQL aktif—termasuk semua database dan
metadata-nya—ke cluster AlloyDB baru. Database Migration Service dapat
membantu Anda melakukan transisi aplikasi yang ada untuk menggunakan
AlloyDB sebagai datastore baru dengan periode nonaktif minimal.
Kumpulan lokalitas terbatas yang disediakan oleh libc:
C.UTF-8
en_US.utf8
Jika database yang ingin Anda impor ke AlloyDB ditetapkan secara default ke lokalitas libc selain dua yang tercantum di sini, Anda tetap dapat mengimpor data, tetapi setelan default tersebut tidak akan diterapkan. Untuk memastikan kueri SQL
yang menggunakan ORDER BY mengurutkan hasilnya dengan benar, Anda mungkin perlu mengambil
langkah tambahan setelah mengimpor data.
Sebaiknya izinkan database baru Anda menggunakan lokalitas default untuk
AlloyDB: C.UTF-8, yang disediakan oleh libc. Kemudian, kaitkan
pengurutan dengan kolom
apa pun yang mungkin terlibat dalam kueri aplikasi Anda dalam klausa
ORDER BY, dengan memberi nama pengurutan berbasis ICU yang sesuai untuk setiap kolom. Anda dapat
melakukannya melalui kueri DDL
ALTER TABLE, seperti berikut:
Cluster AlloyDB baru menentukan ratusan pengurutan
berdasarkan lokalitas yang disediakan ICU, dan Anda dapat menambahkan lebih banyak lagi menggunakan fasilitas
CREATE COLLATION PostgreSQL. Untuk
melihat daftar lengkap nama pengurutan berdasarkan ICU yang ditentukan di
cluster AlloyDB,
jalankan kueri berikut pada salah satu instance-nya:
Selain pengurutan berdasarkan ICU, AlloyDB mendukung
pengurutan bawaan PostgreSQL yang bernama ucs_basic. Pengelompokan ini menggunakan
urutan standar titik kode Unicode untuk memungkinkan pengurutan
yang sangat efisien. Sebaiknya gunakan dengan kolom yang urutan pengurutannya sesuai dengan daftar titik kode Unicode.
Mengekspor data
Anda dapat menggunakan utilitas command line untuk mengekspor data AlloyDB ke file yang disimpan di bucket Cloud Storage, dalam berbagai format:
CSV, mengekspor satu tabel per file,
menggunakan psql.
DMP, menggunakan pg_dump untuk membuat
arsip biner portabel dari seluruh database Anda.
SQL, menggunakan pg_dump untuk membuat daftar
pernyataan DDL dan SQL guna merekonstruksi database Anda.
[[["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-08-25 UTC."],[[["\u003cp\u003eAlloyDB for PostgreSQL supports two primary methods for data migration: manually importing data from files or using Google Cloud Database Migration Service to migrate from an active PostgreSQL instance.\u003c/p\u003e\n"],["\u003cp\u003eData can be imported into AlloyDB from files in CSV, DMP, or SQL formats, located in a Cloud Storage bucket, using \u003ccode\u003epsql\u003c/code\u003e or \u003ccode\u003epg_restore\u003c/code\u003e utilities.\u003c/p\u003e\n"],["\u003cp\u003eGoogle Cloud Database Migration Service allows migrating an entire active PostgreSQL instance, including all databases and metadata, to a new AlloyDB cluster with minimal downtime.\u003c/p\u003e\n"],["\u003cp\u003eAlloyDB supports a range of locales, with a recommendation to use the default \u003ccode\u003eC.UTF-8\u003c/code\u003e locale and to define ICU-based collations for specific columns that require particular sort orders.\u003c/p\u003e\n"],["\u003cp\u003eData can be exported from AlloyDB to files in CSV, DMP, or SQL formats, stored in a Cloud Storage bucket, using \u003ccode\u003epsql\u003c/code\u003e or \u003ccode\u003epg_dump\u003c/code\u003e.\u003c/p\u003e\n"]]],[],null,["# Migration overview\n\nThis page provides an overview of ways to migrate data into and out of\nAlloyDB for PostgreSQL.\n\nImporting data\n--------------\n\nYou can migrate data into AlloyDB through two methods:\n\n- Manually importing files containing your data.\n\n- Using Google Cloud Database Migration Service to migrate the contents of a whole,\n active PostgreSQL instance into a new AlloyDB cluster.\n\n| **Caution:** If your source database uses a default collation based on a locale provided by `libc`, you might need to add ICU-based collations to your tables after importing their data into AlloyDB. For more information, see [Supported locales for imported data](#locales).\n\n### Import archived data from files\n\nAlloyDB lets you import\ndata from files located in a Cloud Storage bucket.\nAlloyDB supports a variety of file formats for data\nimport, including the following:\n\n- [CSV](/alloydb/docs/import-csv-file), with the contents of one table\n per file, loaded using `psql`.\n\n- [DMP](/alloydb/docs/import-dmp-file), a binary archive of a whole\n PostgreSQL database, imported using `pg_restore`.\n\n- [SQL](/alloydb/docs/import-sql-file), a plain-text reconstruction of a\n PostgreSQL database, processed with `psql`.\n\n### Migrate an active instance with Database Migration Service\n\nAs an alternative to manually importing data-dump files, you can use\n[Database Migration Service for AlloyDB](/database-migration/docs/postgresql-to-alloydb).\nThis service lets you migrate the entire contents of an\nactive PostgreSQL instance---including all of its databases and\nmetadata---into a new AlloyDB cluster. Database Migration Service can\nhelp you transition your existing applications to using\nAlloyDB as their new datastore with minimal downtime.\n\n### Supported locales for imported data\n\nAlloyDB supports the following\n[locales](https://www.postgresql.org/docs/16//locale.html):\n\n- The full set of ICU-provided locales.\n- A limited set of locales provided by `libc`:\n - `C.UTF-8`\n - `en_US.utf8`\n\nIf the database you want to import into AlloyDB defaults\nto a `libc` locale other than the two listed here, you can still import\nyour data, but that default won't carry over. To ensure that SQL queries\nusing `ORDER BY` sort their results properly, you might need to take\nadditional steps after importing your data.\n\nWe recommend allowing your new database to use the default locale for\nAlloyDB: `C.UTF-8`, provided by `libc`. Then, associate\n[collations](https://www.postgresql.org/docs/16//collation.html) with any\ncolumns that your application's queries might involve in `ORDER BY`\nclauses, naming an appropriate ICU-based collation for each one. You can\ndo this through [`ALTER TABLE` DDL\nqueries](https://www.postgresql.org/docs/16//sql-altertable.html), such as the following: \n\n ALTER TABLE \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-k\"\u003eTABLE_NAME\u003c/span\u003e\u003c/var\u003e\n ALTER COLUMN \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-k\"\u003eCOLUMN_NAME\u003c/span\u003e\u003c/var\u003e\n SET DATA TYPE \u003cvar translate=\"no\"\u003e\u003cspan class=\"devsite-syntax-n\"\u003eCOLUMN_DATA_TYPE\u003c/span\u003e\u003c/var\u003e\n COLLATE \"\u003cvar translate=\"no\"\u003eCOLLATION_NAME\u003c/var\u003e\";\n\nA new AlloyDB cluster defines hundreds of collations\nbased on ICU-provided locales, and you can add more using [the PostgreSQL\n`CREATE COLLATION` facility](https://www.postgresql.org/docs/16//sql-createcollation.html). To\nsee the full list of ICU-based collation names defined on an\nAlloyDB cluster,\nrun the following query on any of its instances: \n\n SELECT collname FROM pg_collation WHERE collprovider = 'i';\n\nIn addition to ICU-based collations, AlloyDB supports the\nPostgreSQL built-in collation named `ucs_basic`. This collation uses\nthe standard order of Unicode code points to enable especially efficient\nsorting. We recommend its use with columns whose appropriate sort order\nmatches that of the Unicode code-point list.\n\nExporting data\n--------------\n\nYou can use command-line utilities to export your AlloyDB\ndata into files stored on a Cloud Storage bucket, in a variety of formats:\n\n- [CSV](/alloydb/docs/export-csv-file), exporting one table per file,\n using `psql`.\n\n- [DMP](/alloydb/docs/export-dmp-file), using `pg_dump` to create a\n portable, binary archive of your whole database.\n\n- [SQL](/alloydb/docs/export-sql-file), using `pg_dump` to create a list\n of DDL and SQL statements to reconstruct your database.\n\nWhat's next\n-----------\n\n- [Migrate data from a vector database to AlloyDB using LangChain](/alloydb/docs/ai/migrate-data-from-langchain-vector-stores-to-alloydb)."]]