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

# SQL Review with Bytebase GUI

When modifying data in the database, it's crucial to ensure that the changes are both safe and accurate. Bytebase offers a feature called [SQL Review](/sql-review/review-policy/), which allows you to evaluate your SQL changes before they are applied to the database. SQL Review can be invoked from the Bytebase GUI, CI or API.

This is one of the tutorial series of SQL Review:

1. SQL Review with Bytebase GUI (this one)
2. SQL Review with CI (integrated with Database GitOps workflow):Add commentMore actions
   * [Database GitOps with GitHub Actions](/tutorials/gitops-github-workflow/#step-3-configure-sql-review-in-bytebase)
   * [Database GitOps with Azure DevOps](/tutorials/gitops-azure-devops-workflow/#step-3-configure-sql-review-in-bytebase)
   * [Database GitOps with GitLab CI](/tutorials/gitops-gitlab-workflow/#step-3-configure-sql-review-in-bytebase)
   * [Database GitOps with Bitbucket Pipelines](/tutorials/gitops-bitbucket-workflow/#step-3-configure-sql-review-in-bytebase)
3. [SQL Review with Bytebase API](/tutorials/sql-review-api/)
4. [Codify SQL Review Policies with Bytebase API](/tutorials/api-sql-review-policy/)

This tutorial will walk you through using SQL Review in Bytebase with Bytebase GUI to improve your database schema change process. The **Community Plan** is sufficient for completing this tutorial.

## Prerequisites

Make sure you have [Docker](https://www.docker.com/) installed, and if you don’t have important existing Bytebase data locally, you can start over from scratch by `rm -rf ~/.bytebase/data`.

## 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" />

## Configure SQL Review Policies

1. Navigate to **CI/CD** > **SQL Review** in the left menu. Click **+ New SQL Review** to create a new SQL review.

2. Choose `Sample Template` which has 20 enabled rules and click **Confirm and add**. Attach the SQL review to Environment `Prod` and click **Confirm**.

3. You'll see the SQL review is created. Note that there's a warning sign for the `NOT NULL` rule.
   <img src="https://mintcdn.com/dbx/vw8BbfZhlW9y-cr_/content/docs/tutorials/sql-review-gui/bb-sql-review-not-null.webp?fit=max&auto=format&n=vw8BbfZhlW9y-cr_&q=85&s=b218e28f1d051fc069f64f478e94e67f" alt="sql-review-not-null" width="2486" height="1150" data-path="content/docs/tutorials/sql-review-gui/bb-sql-review-not-null.webp" />

## Trigger SQL Review

1. Go to `Sample Project`, navigate to **CI/CD** > **Plans** and click **+ New Plan**.

2. Select `hr_prod` database as the target since the default SQL Review policy is attached to the `Prod` environment. Click **Confirm** to proceed. You can use the **Schema Editor** to visually design the schema, here we'll intentionally uncheck **Not Null** for `nickname` column.

3. The plan will be in `Draft` status. SQL Review will run automatically, and you'll see violations against our defined rules marked in orange as `warning`.

   <img src="https://mintcdn.com/dbx/vw8BbfZhlW9y-cr_/content/docs/tutorials/sql-review-gui/bb-plan-draft-warning.webp?fit=max&auto=format&n=vw8BbfZhlW9y-cr_&q=85&s=54f752143cccb26bb62b6bc7215e8934" alt="plan-draft-warning" width="2476" height="986" data-path="content/docs/tutorials/sql-review-gui/bb-plan-draft-warning.webp" />

   <img src="https://mintcdn.com/dbx/vw8BbfZhlW9y-cr_/content/docs/tutorials/sql-review-gui/bb-plan-draft-warning-detail.webp?fit=max&auto=format&n=vw8BbfZhlW9y-cr_&q=85&s=774386f59287ef96252a0eb7e8374f03" alt="plan-draft-warning-detail" width="2486" height="1154" data-path="content/docs/tutorials/sql-review-gui/bb-plan-draft-warning-detail.webp" />

4. You may resolve this by editing the SQL to add `NOT NULL` constraints. Click **Save** to update the plan. The SQL Review checks will run again and should now pass.

   <img src="https://mintcdn.com/dbx/vw8BbfZhlW9y-cr_/content/docs/tutorials/sql-review-gui/bb-plan-draft-pass.webp?fit=max&auto=format&n=vw8BbfZhlW9y-cr_&q=85&s=979fb07ee30e6ae8bb68ec362610673a" alt="plan-draft-pass" width="2490" height="988" data-path="content/docs/tutorials/sql-review-gui/bb-plan-draft-pass.webp" />

## Summary

Now you have learned how to trigger SQL Review in Bytebase GUI, you may also refer to the [SQL Review](/sql-review/review-policy) document for more details. Next, let's learn how to [trigger SQL Review from your CI API](/tutorials/sql-review-api/).
