Skip to main content
To prevent excessive processing time, SQL Review skips parsing-based checks when the SQL being reviewed exceeds the size limit. The built-in default is 2 MiB (2,097,152 bytes) for the complete SQL text, including all statements. Exceeding it returns a Warning, not a successful review. A configured rule can change the limit and severity; see SQL size limit.
A SQL Review policy defines SQL rules, their parameters, and severity levels. Attach it to environments or projects to apply those rules to their databases. See SQL Review for how checks work and how they differ from human approval.

How SQL Review Works

SQL Review operates as an automated gatekeeper in your database change workflow:
  1. Automatic Triggering: Activates whenever database changes are created or modified
  2. Rule Evaluation: Checks SQL statements against your configured review rules
  3. Instant Feedback: Provides immediate validation results with actionable insights
  4. Enforcement Levels: Applies Error, Warning, or Disabled status based on your policy configuration
The review process validates:
  • Compliance with configured SQL Review Rules
  • Database connectivity and compatibility
  • SQL syntax correctness
  • Schema migration tracking
  • Performance implications
  • Security best practices
sql-advisor

Setting Up SQL Review

Tutorial: SQL Review with Bytebase GUI

Step 1: Create a Review Policy

Navigate to CI/CD → SQL Review in the workspace sidebar. You can create a new policy by:
  1. Starting from a template: Choose a predefined template based on best practices
  2. Building from scratch: Select specific rules for your requirements
bb-sql-review-basic-info

Step 2: Configure Review Rules

Select and configure the SQL Review Rules for each database engine your policy will support. For each rule, set the enforcement level:
  • Error: A violation produces an error finding; required passing-check gates can block deployment
  • Warning: A violation is reported; blocking depends on the workflow’s configured gates
  • Disabled: Rule is not enforced
bb-sql-review-configure-rule
The project setting Require plan checks to pass before creating rollout blocks errors; warnings alone do not block it. In CI, FAIL_ON_ERROR blocks errors and FAIL_ON_WARNING also blocks warnings. See rollout requirements and SQL Review in CI.

Step 3: Attach Policy to Resources

Attach your SQL Review Policy to specific environments or projects to activate it: bb-sql-review-attach-resource

Policy Configuration

Tutorial: Codify SQL Review Policies with Bytebase API

Required Permissions

To configure SQL Review Policies, you need one of the following roles:
  • Workspace Admin: Full access to create and manage policies across all environments and projects
  • DBA: Can create and manage policies for database administration purposes

Policy Scope and Application

SQL Review Policies operate at two levels with different scopes and access points: You can also manage all policies centrally from CI/CD → SQL Review in the workspace sidebar.
Bytebase selects the enabled policy on the database’s effective environment, falling back to its project policy. The policies are not merged. Only one policy can be attached per environment or project. Built-in checks still apply unless overridden by matching configured rules.

Managing Rules

Add or Remove Rules

Customize your policy by adding or removing rules specific to each database engine: bb-sql-review-add-remove

Adjust Rule Severity

Fine-tune enforcement by adjusting rule levels based on your team’s requirements:
  • Use Error for critical standards that must never be violated
  • Use Warning for best practices that should be reviewed
  • Use Disabled to temporarily or permanently skip specific checks

Policy Management

Disable a Policy

Temporarily disable a policy without deleting it when you need to:
  • Perform emergency fixes
  • Test new rule configurations
  • Accommodate special deployment scenarios

Delete a Policy

Remove policies that are no longer needed:
  1. First disable the policy to ensure it’s not actively in use
  2. Then delete it from the policy list
bb-sql-review-policy

SQL size limit

Bytebase checks the total SQL size before parsing. If it exceeds the limit, SQL Review returns the size-limit finding and stops; the remaining SQL Review rules are not evaluated for that input. Other Plan checks report their results separately. Configure Restrict the SQL file size for the database engine to override the default limit or severity. The UI labels the numeric field Maximum size in MB. Reduce the SQL input or review the limit with the policy owner, then rerun SQL Review. A size-limit warning means the remaining rules were skipped, even if the workflow permits deployment with warnings.