Use Spanner migration tool for MySQL schema migration Stay organized with collections Save and categorize content based on your preferences.
This document describes how to use the Spanner migration tool (SMT)to migrate your MySQL schema to Spanner. SMT can read your MySQLschema and convert it to Spanner schema, remove duplicate indexes,and offer schema optimization suggestions.
Before you begin
Ensure you've installed and set up SMT.For more information, seeSet up Spanner migration tool.
Configure schema
Once you've connected your source database and Spanner withSMT, the tool reads your MySQL schema andconverts it to Spanner schema. The tool doesn't convertstored procedures or triggers.
To view a report on the schema conversion, go to theConfigure Schema pageon the web UI and clickView assessment.
This report provides an overall assessment of schema conversion and also providesdetailed table-level and column-level conversion information, suggestions andwarnings, and lists schema elements that couldn't be converted.
Modify schema
On theConfigure Schema page, you can view your source MySQL databaseschema and the draft of the Spanner schema. You can also modifythe converted schema to fit your organization's schema requirements.
You can select tables or indexes, view and manage their schema.
Tables
Select a table you want to modify on theSpanner draft tab onthe web UI. You can drop or restore tables on this tab.For each table you select, you can view the following list of tabs:
- Columns
- Primary key
- Foreign key
- Check constraints
- SQL
Column
TheColumn tab provides information about the columns in the selected table.You can edit the columns in the following ways:
- Modify a column name
- Delete a column
- Change the column's data type
- Add auto-generated IDs
- Modify the default value
- Modify the null property
Besides editing existing columns in the Spanner draft,you can also add new columns to the selected table.
Primary key
You can view and edit the table's primary key from thePrimary key tab inthe following ways:
- Add or remove a column from a primary key
- Change the order of columns in a primary key
You can also use auto-generated columns for primary keys. You can choose oneof the following to create auto-generated columns.
- UUID function:generate a UUID v4 as part of the table's primary key
defaultexpression. - Bit-reverse function:map existing integer keys as a bit-reversed sequence.
Foreign key
You can view and edit the table's foreign key from theForeign key tab inthe following ways:
- Change the foreign key constraint name
- Drop the foreign key if you want to use an interleaved table instead
- Convert an interleaved table back to a foreign key
Check constraints
You can view and edit the table's check constraints using theCheck constraints tab in the following ways:
- Change the check constraint name or condition
- Remove the check constraint
SQL
You can view the Spanner data definition languagein the GoogleSQL dialect in theSQL tab.
Indexes
Select an index you want to modify on theSpanner draft tabon the web UI. You can edit the index in the following ways:
- Drop or restore the index
- Add a secondary index
- View the Spanner DDL in theSQL tab.
Prepare migration
Once you complete configuring your schema, you can download the schema as atext file and use the DDL to create the schema in your targetSpanner instance.
To download the schema, go to thePrepare Migration page on the web UI anddo the following:
- In theMigration Mode drop-down, selectSchema.
- ClickDownload to download the schema DDL as a text file.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2026-02-05 UTC.