[[["易于理解","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-09-05。"],[],[],null,["# Use Spanner migration tool for MySQL schema migration\n\nThis document describes how to use the Spanner migration tool (SMT)\nto migrate your MySQL schema to Spanner. SMT can read your MySQL\nschema and convert it to Spanner schema, remove duplicate indexes,\nand offer schema optimization suggestions.\n\nBefore you begin\n----------------\n\nEnsure you've installed and set up SMT.\nFor more information, see\n[Set up Spanner migration tool](/spanner/docs/set-up-spanner-migration-tool).\n\nConfigure schema\n----------------\n\nOnce you've connected your source database and Spanner with\nSMT, the tool reads your MySQL schema and\nconverts it to Spanner schema. The tool doesn't convert\nstored procedures or triggers.\n\nTo view a report on the schema conversion, go to the **Configure Schema** page\non the web UI and click **View assessment**.\n\nThis report provides an overall assessment of schema conversion and also provides\ndetailed table-level and column-level conversion information, suggestions and\nwarnings, and lists schema elements that couldn't be converted.\n\nModify schema\n-------------\n\nOn the **Configure Schema** page, you can view your source MySQL database\nschema and the draft of the Spanner schema. You can also modify\nthe converted schema to fit your organization's schema requirements.\n\nYou can select tables or indexes, view and manage their schema.\n\n### Tables\n\nSelect a table you want to modify on the **Spanner draft** tab on\nthe web UI. You can drop or restore tables on this tab.\nFor each table you select, you can view the following list of tabs:\n\n- Columns\n- Primary key\n- Foreign key\n- Check constraints\n- SQL\n\n#### Column\n\nThe **Column** tab provides information about the columns in the selected table.\nYou can edit the columns in the following ways:\n\n- Modify a column name\n- Delete a column\n- Change the column's data type\n- Add auto-generated IDs\n- Modify the default value\n- Modify the null property\n\nBesides editing existing columns in the Spanner draft,\nyou can also add new columns to the selected table.\n\n#### Primary key\n\nYou can view and edit the table's primary key from the **Primary key** tab in\nthe following ways:\n\n- Add or remove a column from a primary key\n- Change the order of columns in a primary key\n\nYou can also use auto-generated columns for primary keys. You can choose one\nof the following to create auto-generated columns.\n\n- **[UUID function](/spanner/docs/reference/standard-sql/utility-functions#generate_uuid)** : generate a UUID v4 as part of the table's primary key `default` expression.\n- **[Bit-reverse function](/spanner/docs/reference/standard-sql/bit_functions#bit_reverse)**: map existing integer keys as a bit-reversed sequence.\n\n#### Foreign key\n\nYou can view and edit the table's foreign key from the **Foreign key** tab in\nthe following ways:\n\n- Change the foreign key constraint name\n- Drop the foreign key if you want to use an interleaved table instead\n- Convert an interleaved table back to a foreign key\n\n#### Check constraints\n\nYou can view and edit the table's check constraints using the\n**Check constraints** tab in the following ways:\n\n- Change the check constraint name or condition\n- Remove the check constraint\n\n#### SQL\n\nYou can view the Spanner data definition language\nin the GoogleSQL dialect in the **SQL** tab.\n\n### Indexes\n\nSelect an index you want to modify on the **Spanner draft** tab\non the web UI. You can edit the index in the following ways:\n\n- Drop or restore the index\n- Add a secondary index\n- View the Spanner DDL in the **SQL** tab.\n\nPrepare migration\n-----------------\n\nOnce you complete configuring your schema, you can download the schema as a\ntext file and use the DDL to create the schema in your target\nSpanner instance.\n\nTo download the schema, go to the **Prepare Migration** page on the web UI and\ndo the following:\n\n1. In the **Migration Mode** drop-down, select **Schema**.\n2. Click **Download** to download the schema DDL as a text file."]]