> ## 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.

# Batch Change with Database Group

Bytebase simplifies deploying changes across multiple databases simultaneously. This tutorial demonstrates how to use **Environments** and **Database Groups** to efficiently manage batch changes across your database fleet.

<img src="https://mintcdn.com/dbx/wzfDanOtVHdPe4nL/content/docs/tutorials/batch-change-with-database-group/database-group-banner.webp?fit=max&auto=format&n=wzfDanOtVHdPe4nL&q=85&s=13a540cf93879229a0f21e2cf90c6b4b" alt="database-group-banner" width="1715" height="1500" data-path="content/docs/tutorials/batch-change-with-database-group/database-group-banner.webp" />

## Prerequisites

* **Environment**: Available in all plans
* **Database Groups**: Requires Pro Plan or higher ([request trial](https://www.bytebase.com/pricing))

## Procedure

## Step 1 - Start Bytebase with sample data

1. Ensure Docker is running, then start the Bytebase container:

   ```bash theme={null}
   docker run --rm --init \
     --name bytebase \
     --publish 8080:8080 --pull always \
     --volume ~/.bytebase/data:/var/opt/bytebase \
     bytebase/bytebase:latest
   ```

   <img src="https://mintcdn.com/dbx/vw8BbfZhlW9y-cr_/content/docs/tutorials/shared/dk-bb-running.webp?fit=max&auto=format&n=vw8BbfZhlW9y-cr_&q=85&s=cf0be18b5f9bfc3ff7c06b8276cd2466" alt="dk-bb-running" width="1536" height="120" data-path="content/docs/tutorials/shared/dk-bb-running.webp" />

2. Open Bytebase in [localhost:8080](http://localhost:8080/), fill in the fields and click **Create admin account**. You'll be redirected to Workspace.

   <img src="https://mintcdn.com/dbx/vw8BbfZhlW9y-cr_/content/docs/tutorials/shared/account.webp?fit=max&auto=format&n=vw8BbfZhlW9y-cr_&q=85&s=89bfcf723a14ae15e941e00db24435b4" alt="account" width="3840" height="1936" data-path="content/docs/tutorials/shared/account.webp" />

3. During workspace setup, choose the built-in sample data.

   <img src="https://mintcdn.com/dbx/vw8BbfZhlW9y-cr_/content/docs/tutorials/shared/bb-setup-built-in-sample.webp?fit=max&auto=format&n=vw8BbfZhlW9y-cr_&q=85&s=8950dabf39d43da14c0e690c95084a48" alt="setup-built-in-sample-data" width="1024" height="664" data-path="content/docs/tutorials/shared/bb-setup-built-in-sample.webp" />

## Step 2 - Set up environments and databases

1. Navigate to **Environments**. Rename `Prod` to `ProdAsia`, then create two new environments: `ProdEU` and `ProdNA`.

   <img src="https://mintcdn.com/dbx/wzfDanOtVHdPe4nL/content/docs/tutorials/batch-change-with-database-group/bb-env-3prod.webp?fit=max&auto=format&n=wzfDanOtVHdPe4nL&q=85&s=38dadd8d1bc3fee58ed653ea443a3ddd" alt="bb-env-3prod" width="2860" height="1378" data-path="content/docs/tutorials/batch-change-with-database-group/bb-env-3prod.webp" />

2. Click **Select Project** in the top bar, then **New Project**. Name it `Batch Change Project` and click **Create**.

3. In the new project, navigate to **Database > Databases** and click **+ New DB**. Create `demo-test` on the Test instance. Click **Rollout** when the issue appears.

4. Similarly, create the following databases:

   * `demo-prod-1` and `demo-prod-2` on `ProdAsia`
   * `demo-prod-3` and `demo-prod-4` on `ProdEU`
   * `demo-prod-5` and `demo-prod-6` on `ProdNA`

   <img src="https://mintcdn.com/dbx/wzfDanOtVHdPe4nL/content/docs/tutorials/batch-change-with-database-group/bb-prod-db.webp?fit=max&auto=format&n=wzfDanOtVHdPe4nL&q=85&s=4ee34a3b4013e0b85d7b30e4321440ed" alt="bb-prod-db" width="1243" height="599" data-path="content/docs/tutorials/batch-change-with-database-group/bb-prod-db.webp" />

## Step 3 - Execute batch changes by environment (All plans)

1. Navigate to **CI/CD > Plans**, click **+ New Plan**, and select **Schema Change**.

2. Select all databases and click **Confirm**.

3. Enter the following SQL, then click **Create** and **Ready for review**:

   ```SQL theme={null}
      CREATE TABLE t2("id" INTEGER NOT NULL);
   ```

4. The **Overview** and **Rollout** tabs display four stages: Test, ProdAsia, ProdEU, and ProdNA. You can deploy changes to individual databases or entire stages.

   <img src="https://mintcdn.com/dbx/wzfDanOtVHdPe4nL/content/docs/tutorials/batch-change-with-database-group/bb-overview-4-stages.webp?fit=max&auto=format&n=wzfDanOtVHdPe4nL&q=85&s=55870abf239198176ea5f57ab1f76862" alt="overview-4-stages" width="1241" height="600" data-path="content/docs/tutorials/batch-change-with-database-group/bb-overview-4-stages.webp" />

   <img src="https://mintcdn.com/dbx/wzfDanOtVHdPe4nL/content/docs/tutorials/batch-change-with-database-group/bb-rollout-4-stages.webp?fit=max&auto=format&n=wzfDanOtVHdPe4nL&q=85&s=c6596ac038869227fde07e8364a909f9" alt="rollout-4-stages" width="1239" height="619" data-path="content/docs/tutorials/batch-change-with-database-group/bb-rollout-4-stages.webp" />

5. Go to the **Rollout** tab and click **Run** in the Test stage to execute.

   <img src="https://mintcdn.com/dbx/wzfDanOtVHdPe4nL/content/docs/tutorials/batch-change-with-database-group/bb-rollout-half-complete.webp?fit=max&auto=format&n=wzfDanOtVHdPe4nL&q=85&s=9ec13ea90d5f228bb73adba0ab769a92" alt="rollout-half-complete" width="1243" height="605" data-path="content/docs/tutorials/batch-change-with-database-group/bb-rollout-half-complete.webp" />

## Step 4 - Use database groups (Pro/Enterprise)

We need first to upgrade to Pro/Enterprise Plan to use Database Group.

1. Click the **Setting icon** on the top right, and then click **Workspace > Subscription** to upload the license.

2. Click the pen icon, select the instances you want to enable Enterprise features , and click **Confirm**.

   <img src="https://mintcdn.com/dbx/wzfDanOtVHdPe4nL/content/docs/tutorials/batch-change-with-database-group/bb-subscription.webp?fit=max&auto=format&n=wzfDanOtVHdPe4nL&q=85&s=5f7ce94b8be1eb04063606353eaff291" alt="bb-subscription" width="3080" height="590" data-path="content/docs/tutorials/batch-change-with-database-group/bb-subscription.webp" />

3. Navigate to **Database > Groups** in your project. Click **+ New database group** and configure:

   * **Name:** `demo-prod-all`
   * **Condition:** `resource.database_name startsWith demo-prod`

   <img src="https://mintcdn.com/dbx/wzfDanOtVHdPe4nL/content/docs/tutorials/batch-change-with-database-group/bb-groups.webp?fit=max&auto=format&n=wzfDanOtVHdPe4nL&q=85&s=4e669a5c95722e8645e36a5164cf8552" alt="bb-groups" width="1366" height="667" data-path="content/docs/tutorials/batch-change-with-database-group/bb-groups.webp" />

4. Go to **CI/CD > Plans**, click **+ New Plan**, select **Schema Migration**. Switch to the **Database Group** tab, select `demo-prod-all`, and click **Confirm**.

5. Enter the following SQL, then click **Create** and **Ready for review**:

   ```SQL theme={null}
      CREATE TABLE t3("id" INTEGER NOT NULL);
   ```

6. The **Overview** and **Rollout** tabs now show 3 production stages. Click **Run** in the ProdAsia stage to execute.

   <img src="https://mintcdn.com/dbx/wzfDanOtVHdPe4nL/content/docs/tutorials/batch-change-with-database-group/bb-overview-3-stages.webp?fit=max&auto=format&n=wzfDanOtVHdPe4nL&q=85&s=2d14b20c0696a3ba1bc5e45ab5ce065c" alt="bb-overview-3-stages" width="1363" height="608" data-path="content/docs/tutorials/batch-change-with-database-group/bb-overview-3-stages.webp" />

   <img src="https://mintcdn.com/dbx/wzfDanOtVHdPe4nL/content/docs/tutorials/batch-change-with-database-group/bb-rollout-3-stages.webp?fit=max&auto=format&n=wzfDanOtVHdPe4nL&q=85&s=1168b9e332fa9e1405343c3729cf86eb" alt="bb-rollout-3-stages" width="1365" height="594" data-path="content/docs/tutorials/batch-change-with-database-group/bb-rollout-3-stages.webp" />

## Summary

You've learned how to:

* Group databases by environment for staged rollouts
* Use Database Groups to target databases matching specific criteria
* Execute batch changes across multiple databases efficiently
