> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bytebase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Schema Synchronization

<Card title="Tutorial: How to Synchronize Database Schemas" icon="graduation-cap" href="/tutorials/how-to-synchronize-database-schemas" horizontal />

Bytebase supports synchronizing a specified schema version of one source database to one or multiple target databases.
You can use Schema Synchronization to:

* Propagate the schema changes from the one database to others.
* Revert the database schema to an old version.

The overall workflow:

<img src="https://mintcdn.com/dbx/afRbc5nzzK45dH85/content/docs/change-database/synchronize-schema/workflow.webp?fit=max&auto=format&n=afRbc5nzzK45dH85&q=85&s=f82998683c5fde7204c630dc65203a56" alt="workflow" width="3433" height="1846" data-path="content/docs/change-database/synchronize-schema/workflow.webp" />

1. Compare a source database schema with one or multiple target databases' schema.
2. Generate the suggested DDL statements (e.g. `ALTER TABLE`) to transit the source database schema state to each of the target database schema.
3. Create an issue.
4. Deploy the DDL statements to the targeted databases.

## Supported Objects

| Object                        | MySQL                                | PostgreSQL                       | TiDB                         | Oracle                                    | SQL Server                 |
| ----------------------------- | ------------------------------------ | -------------------------------- | ---------------------------- | ----------------------------------------- | -------------------------- |
| **Schema**                    | —                                    | ✅                                | —                            | ✅                                         | ✅                          |
| **Table**                     | ✅                                    | ✅                                | ✅                            | ✅                                         | ✅                          |
| **Column**                    | ✅                                    | ✅                                | ✅                            | ✅                                         | ✅                          |
| **Primary Key**               | ✅                                    | ✅                                | ✅                            | ✅                                         | ✅                          |
| **Foreign Key**               | ✅                                    | ✅                                | ✅                            | ✅                                         | ✅                          |
| **Index**                     | ✅ Regular, Unique, Fulltext, Spatial | ✅ Including Expression & Partial | ✅                            | ✅ Regular, Unique, Bitmap, Function-based | ✅ Clustered, Non-clustered |
| **Check Constraint**          | ✅ (8.0+)                             | ✅                                | ❌ (metadata sync limitation) | ✅                                         | ✅                          |
| **View**                      | ✅                                    | ✅                                | ✅                            | ✅                                         | ✅                          |
| **Materialized View**         | —                                    | ✅                                | —                            | ✅                                         | ❌                          |
| **Generated/Computed Column** | ✅ STORED/VIRTUAL                     | ✅ STORED                         | ✅                            | ✅ Virtual                                 | ✅ Computed                 |
| **Identity/Auto Column**      | ✅ AUTO\_INCREMENT                    | ✅ SERIAL/IDENTITY                | ✅ AUTO\_RANDOM               | ✅ IDENTITY (12c+)                         | ✅ IDENTITY                 |
| **Partitioning**              | ✅ KEY, HASH, RANGE, LIST             | ✅                                | ✅                            | ✅ RANGE, LIST, HASH, COMPOSITE            | ❌                          |
| **Sequence**                  | —                                    | ✅                                | —                            | ✅                                         | ✅                          |
| **Trigger**                   | ✅                                    | ✅                                | —                            | ✅                                         | ✅                          |
| **Function**                  | ✅                                    | ✅                                | —                            | ✅                                         | ✅                          |
| **Procedure**                 | ✅                                    | ✅                                | —                            | ✅                                         | ✅                          |
| **Package**                   | —                                    | —                                | —                            | ✅                                         | —                          |
| **Custom Type**               | —                                    | ✅ Enum only                      | —                            | ✅                                         | ✅                          |
| **Extension**                 | —                                    | ✅                                | —                            | —                                         | —                          |
| **Comments**                  | ✅                                    | ✅                                | ✅                            | ✅                                         | ✅                          |

## How to use

### Step 1 - Go to the **Sync Schema** page

Click the **Database > Sync Schema** button in the left navigation bar.

### Step 2 - Select source schema

You need to select the project and source database schema version that you want to synchronize.

<img src="https://mintcdn.com/dbx/afRbc5nzzK45dH85/content/docs/change-database/synchronize-schema/select-source-schema.webp?fit=max&auto=format&n=afRbc5nzzK45dH85&q=85&s=6553e22b304e349c92e9f2c6705c1cdd" alt="select-source-schema" width="2792" height="1558" data-path="content/docs/change-database/synchronize-schema/select-source-schema.webp" />

### Step 3 - Select target databases

Select the target databases that will be synchronized with the chosen schema version in the previous step.

<img src="https://mintcdn.com/dbx/afRbc5nzzK45dH85/content/docs/change-database/synchronize-schema/select-target-databases.webp?fit=max&auto=format&n=afRbc5nzzK45dH85&q=85&s=f700a33460871e8f23085e6c1bf4a684" alt="select-target-databases" width="3426" height="1904" data-path="content/docs/change-database/synchronize-schema/select-target-databases.webp" />

After you have selected a target database, Bytebase will show a schema diff between the two databases and generate the DDL statements. And you can further edit the generated content.

<img src="https://mintcdn.com/dbx/afRbc5nzzK45dH85/content/docs/change-database/synchronize-schema/diff-preview.webp?fit=max&auto=format&n=afRbc5nzzK45dH85&q=85&s=fe70fd6cde65dbbf60edd40d9f73fcc1" alt="diff-preview" width="3428" height="1914" data-path="content/docs/change-database/synchronize-schema/diff-preview.webp" />

### Step 4 - Preview issue

With the generated DDL statements, you can preview and create an **Edit Schema** issue. This kicks off the [change workflow](/change-database/change-workflow) for the applied database.
