除了手动导入数据转储文件之外,您还可以使用 Database Migration Service for AlloyDB。借助此服务,您可以将活跃 PostgreSQL 实例的全部内容(包括所有数据库和元数据)迁移到新的 AlloyDB 集群中。Database Migration Service 可帮助您以尽可能短的停机时间将现有应用迁移到 AlloyDB,并作为新的数据存储区存在。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-19。"],[[["\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)."]]