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

> Bytebase reviews the SQL of a database change in two ways, with rules and with an AI model.

Bytebase reviews the SQL of a database change before it rolls out, in two ways:

* **SQL Review Rules** check each statement against rules you turn on for each database engine, such as "every table needs a primary key". The same SQL always gets the same result.
* **AI SQL Review** adds a review by your configured AI model, which reads the statements together with the target database's schema and statistics to look for risks in the change. It follows a review policy you can customize in plain language.

Both run on the plan, and their results appear side by side under **Automated review** in the plan's **Review** section. You configure both in the workspace sidebar under **CI/CD** > **SQL Review**.

| | SQL Review Rules | AI SQL Review |
| - | - | - |
| **How it checks** | Parses each statement and applies the rules. | An AI model reads the statements and looks up the schema and statistics it needs. |
| **What you configure** | A SQL Review policy: rules, parameters, and a **P0** or **P1** level for each rule ([**Error** or **Warning** before 3.25.0](https://docs.bytebase.com/sql-review/review-policy.md#step-2-configure-review-rules)), attached to environments or projects. | An optional policy in plain language, for the workspace and for each project. Default checks run without one. |
| **Where it runs** | Plans in the console, GitOps CI, and the API. | Database change plans in the console. |
| **What it reports** | A finding for each rule a statement breaks. | Inline comments on the SQL, each with a priority, evidence, and a suggested fix. |
| **Requirements** | None. | The [AI Assistant](https://docs.bytebase.com/ai-assistant.md) setting and the **Enterprise** plan. |

Use SQL Review Rules for checks that must give the same result every time, and add AI SQL Review for a broader review that follows a policy you customize in plain language.

> [card] [SQL Review Rules](https://docs.bytebase.com/sql-review/review-policy.md)
>
> Create a SQL Review policy and attach it to environments or projects.

> [card] [AI SQL Review](https://docs.bytebase.com/sql-review/ai-review.md)
>
> Turn on AI SQL Review and write your own review policy.

For how checks fit into the change workflow and how they differ from human approval, see [SQL Review concepts](https://docs.bytebase.com/concepts/sql-review.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.