Migrate your schema

Migrating a schema from your source database to Spanner involves amulti-step process that combines automated tooling with manual analysisand refinement. The following steps outline the recommended approach:

  1. Schema extraction: Extract the schema definition (DDL) from your sourcedatabase.

  2. Initial conversion: You can consider using an automatedschema conversion tool, such asSpanner migration tool (SMT),which can handle many of the basic data type mapping and structuralconversions.

  3. Detailed schema review and refinement: Consider converting your sourcedatabase schema that's more compatible with Spanner in smaller,deliberate changes, that can be individually tested and optimized to reducethe risk of changing everything at once.

    1. Data type mapping: Review and refine the data type mapping generatedby SMT. Ensure that Spanner data types accurately representthe range, precision, and semantics of the corresponding source databasetypes.
    2. Primary keys and interleaving: Identify opportunities to useSpanner's interleaved tables to model parent-childrelationships present in the source database schema. Choose appropriateprimary key strategiesfor Spanner such as using UUIDs. SMT can help you choose anappropriate primary key strategy. Considerthe implications for data locality and hotspot avoidance. Evaluate howforeign key constraints are used in your source database and determinehow to handle them in Spanner. For more information, seeParent-child table relationships.
    3. Index optimization: Analyze existing indexes in your source databaseand design Spanner indexes to optimize query performance.Consider dropping infrequently used indexes.
    4. Remove incompatibilities: Remove or rewrite any source databasespecific features that aren't supported in Spanner. Forexample, Spanner doesn't support stored procedures ortriggers. This might require you to refactor application code.
  4. Schema deployment: Deploy the Spanner schema to adevelopment or staging environment.

  5. Iterative testing and refinement:Load sample dataand test the schema with representative application interactions. Monitorperformance and identify areas of improvement. Refine the schema based on theresults of testing. Repeat this process until the schema meets your application'sperformance and functional requirements.

  6. Schema validation: Develop scripts or procedures to compare the structureof the source database and Spanner schemas to ensure that theconversion was performed correctly.

  7. Final schema deployment: Deploy the validated and refined schema to theSpanner production instance.

Source specific guides

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-19 UTC.