CNCF Landscape includes Bytebase as the first-ever database CI/CD solution Check Now

SQL Review Guide

An online tool for DBA to generate the SQL review / DDL guideline.

Advanced Template

Comprehensive policy where you have total protection and best practices for your databases.

Basic Template

Basic coverage to defend your databases from common misusage.

Database Review Guide

Database

Can only drop the database if there's no table in it.

    System

    • Allow list:
      utf8mb4

    • Allow list:
      utf8mb4_0900_ai_ci
    Column

    Enforce the required columns in each table.

    • Required column names:
      id created_ts updated_ts creator_id updater_id

    Set the disallow list for column type.

    • Disallow list:
      JSON

    Columns cannot have NULL value.

      Disallow change column type.

        Require default value for not NULL column.

          Disallow changing column order.

            Auto-increment column requires integer type.

              Disallow set charset for column.

                Auto-increment column must be the UNSIGNED type.

                  Configure whether the column requires comments and the maximum comment length.

                  • Require comment: true
                  • Max length: 64

                  Force to change CHAR to VARCHAR if maximum length is reached.

                  • Maximum length: 20

                  Set initial value for auto-increment column.

                  • Initial value: 1

                  Limit the count of NOW(), CURRENT_TIME() and CURRENT_TIMESTAMP() columns.

                    Schema

                    MySQL and TiDB support checking whether the schema change is backward compatible.

                      Table

                      Require the table to have a primary key.

                        Disallow the foreign key in the table.

                          Only tables named with specific patterns can be deleted. The requires users to do a rename before dropping the table. The table name must have "_del" suffix by default.

                          • Table name format (regex): _del$

                          Configure whether the table requires comments and the maximum comment length.

                          • Require comment: true
                          • Max length: 64
                          Statement

                          Disallow 'SELECT *' statement.

                            Require 'WHERE' clause.

                              Disallow leading '%' in LIKE, e.g. LIKE foo = '%x' is not allowed.

                                Disallow using commit in the issue.

                                  Disallow "LIMIT" for "INSERT", "UPDATE", "DELETE" statement.

                                    Disallow "ORDER BY" for "UPDATE", "DELETE" statement.

                                      Disallow using multiply "ALTER TABLE" statement for same table.

                                        Must specify the column to insert. For example, "INSERT INTO t (id,name) VALUES(...)".

                                          • Maximum insert amount: 1000

                                          Limit the "DELETE" and "UPDATE" affected row

                                          • Maximum affected rows: 1000

                                          Dry run DML statements by EXPLAIN.

                                            Naming

                                            Enforce the table name format and length limit. Default snake_lower_case with 63 characters.

                                            • Table name format (regex): ^[a-z]+(_[a-z]+)*$
                                            • Length limit: 63

                                            Enforce the column name format and length limit. Default snake_lower_case with 63 characters.

                                            • Column name format (regex): ^[a-z]+(_[a-z]+)*$
                                            • Length limit: 63

                                            Enforce the unique key name format and length limit. Default uk_<table_name>_<column_list> or empty within 63 characters.

                                            • Unique key name format: ^$|^uk_{{table}}_{{column_list}}$
                                            • Length limit: 63

                                            Enforce the primary key name format and length limit. Default pk_<table_name>_<column_list> or empty within 63 characters.

                                            • Primary key name format: ^$|^pk_{{table}}_{{column_list}}$
                                            • Length limit: 63

                                            Enforce the index name format and length limit. Default idx_<table_name>_<column_list> or empty within 63 characters.

                                            • Index name format: ^$|^idx_{{table}}_{{column_list}}$
                                            • Length limit: 63

                                            Enforce the foreign key name format and length limit. Default fk_<referencing_table>_<referencing_column>_<referenced_table>_<referenced_column> or empty within 63 characters.

                                            • Foreign key name format: ^$|^fk_{{referencing_table}}_{{referencing_column}}_{{referenced_table}}_{{referenced_column}}$
                                            • Length limit: 63

                                            Enforce the auto-increment column name format and length limit. Default id within 63 characters.

                                            • Auto-increment column name format (regex): ^id$
                                            • Length limit: 63
                                            Index

                                            Disallow using BLOB type column in index.

                                              Enforce the primary key type to be INT or BIGINT.

                                                Limit the related row count in a single index.

                                                • Maximum column count: 5

                                                • Maximum index count: 5
                                                Engine

                                                Require InnoDB as the storage engine for MySQL.

                                                  Made by Bytebase at 2022-12-07