3. Column Definition
Auto-increment columns must not use signed integers
Code: SignedInteger4IdentityColumnDisallowed
Rule Description: The use of signed integer types in auto-increment columns is prohibited to avoid potential overflow issues.
Warning Level: Warning
Review Object: CREATE TABLE
Trigger Condition: Auto-increment columns use signed integer types.
Configurable: Yes
Example: The expression can be configured as unsigned int/unsigned bigint
, indicating that auto-increment columns should use these unsigned integer types.
Supported Database Types: All
Auto-increment columns should start with an initial value of 0/1
Code: InitValue4IdentityColumn
Rule Description: Auto-increment columns should start with an initial value of 0 or 1 to ensure that the generated key values are unique.
Warning Level: Warning
Review Object: CREATE TABLE
Trigger Condition: The initial value of auto-increment columns is not 0 or 1.
Configurable: Yes
Example: The expression can be configured as 1
, indicating that the initial value of auto-increment columns should start from 1.
Supported Database Types: All
Auto-increment sequence exhaustion warning
Code: CacheExhausted4IdentityColumn
Rule Description: A warning should be issued when the auto-increment sequence approaches its maximum value to avoid sequence exhaustion.
Warning Level: Warning
Review Object: CREATE TABLE
Trigger Condition: The current value of the auto-increment sequence is close to its maximum value preset threshold (e.g., 0.8).
Configurable: Yes
Example: The expression can be configured as 0.8
, indicating that a warning should be issued when the auto-increment sequence reaches 80% of its maximum value.
Supported Database Types: All
ENUM data type is prohibited
Code: EnumDataTypeDisallowed
Rule Description: The use of the ENUM data type is prohibited because it is not a SQL standard type, which may lead to portability issues and difficulties in data maintenance.
Warning Level: Warning
Review Object: CREATE TABLE, ALTER TABLE ADD COLUMN
Trigger Condition: Columns are defined using the ENUM data type.
Configurable: No
Supported Database Types: All
SET data type is prohibited
Code: SetDataTypeDisallowed
Rule Description: The use of the SET data type is prohibited because it may lead to increased complexity in data maintenance and querying.
Warning Level: Warning
Review Object: CREATE TABLE, ALTER TABLE ADD COLUMN
Trigger Condition: Columns are defined using the SET data type.
Configurable: No
Supported Database Types: All
Timestamp columns must specify default values
Code: DefaultValue4TimeStampColumnsRequired
Rule Description: Timestamp columns must specify default values to ensure that a reasonable default time is automatically generated when no explicit timestamp value is inserted.
Warning Level: Warning
Review Object: CREATE TABLE, ALTER TABLE ADD COLUMN
Trigger Condition: Timestamp columns do not specify default values.
Configurable: No
Supported Database Types: All
Integer types are recommended to use INT(10) or BIGINT(20)
Code: UseInt10Bigint20ForInteger
Rule Description: It is recommended to use INT(10) or BIGINT(20) for integer fields to optimize storage space and performance.
Warning Level: Warning
Review Object: CREATE TABLE, ALTER TABLE MODIFY COLUMN
Trigger Condition: Integer fields do not use the recommended INT(10) or BIGINT(20).
Configurable: No
Supported Database Types: All
Precise floating-point numbers are recommended to use DECIMAL or Number
Code: UseDecimalForNumericColumns
Rule Description: For floating-point numbers that require precise representation, it is recommended to use the DECIMAL type to avoid precision issues in floating-point arithmetic.
Warning Level: Warning
Review Object: CREATE TABLE, ALTER TABLE MODIFY COLUMN
Trigger Condition: Floating-point types are used instead of DECIMAL.
Configurable: No
Supported Database Types: All
Non-null fields must have default values
Code: DefaultValue4NonNullColumnsRequired
Rule Description: Fields defined as non-null (NOT NULL) must specify default values to avoid errors when inserting data.
Warning Level: Warning
Review Object: CREATE TABLE, ALTER TABLE MODIFY COLUMN
Trigger Condition: Non-null fields do not specify default values.
Configurable: No
Supported Database Types: All
Tables must define update timestamp columns
Code: UpdateTimeStampColumnsRequired
Rule Description: It is required that tables include update timestamp columns to record the last update time of the data, which helps track data changes.
Warning Level: Warning
Review Object: CREATE TABLE, ALTER TABLE ADD COLUMN
Trigger Condition: Tables do not define update timestamp columns.
Configurable: No
Supported Database Types: All
VARCHAR field length exceeds threshold
Code: Length4VarcharExceedThreshold
Rule Description: The maximum length of VARCHAR fields is limited to avoid performance issues and unnecessary storage costs.
Warning Level: Warning
Review Object: CREATE TABLE, ALTER TABLE MODIFY COLUMN
Trigger Condition: The length of VARCHAR fields exceeds the preset threshold (e.g., 10000).
Configurable: Yes
Example: The expression can be configured as 10000
, indicating that the length of VARCHAR fields should not exceed 10000 characters.
Supported Database Types: All
CHAR types exceeding threshold length should be changed to VARCHAR types
Code: Length4CharColumnExceedThreshold
Rule Description: When the length of CHAR type fields exceeds a certain threshold, it should be considered to change to VARCHAR types to dynamically store data with varying lengths.
Warning Level: Notice
Review Object: CREATE TABLE, ALTER TABLE MODIFY COLUMN
Trigger Condition: The length of CHAR fields exceeds the preset threshold (e.g., 64).
Configurable: Yes
Example: The expression can be configured as 64
, indicating that the length of CHAR fields should not exceed 64 characters.
Supported Database Types: All
Timestamp type is prohibited
Code: TimestampDatatypeDisallowed
Rule Description: The use of the timestamp type is prohibited because it may have a maximum value limit and time zone conversion issues.
Warning Level: Warning
Review Object: CREATE TABLE, ALTER TABLE ADD COLUMN
Trigger Condition: Columns are defined using the timestamp type.
Configurable: No
Supported Database Types: MySQL
Prohibited data types
Code: DataTypesDisallowed
Rule Description: Certain data types are prohibited because they are not supported or not recommended for use.
Warning Level: Warning
Review Object: CREATE TABLE, ALTER TABLE ADD COLUMN
Trigger Condition: Prohibited data types are used (e.g., JSON, BJSON, XML).
Configurable: Yes
Example: The expression can be configured as JSON,BJSON,XML
, indicating that the use of JSON, BJSON, and XML data types is prohibited.
Supported Database Types: All
Time or date-time type fields must set default values or default values must not be empty
Code: DefaultValue4TimeOrDateTimeColumnsRequired
Rule Description: Fields of time or date-time types must set default values to avoid generating invalid date-time values during insertion operations.
Warning Level: Warning
Review Object: CREATE TABLE, ALTER TABLE ADD COLUMN
Trigger Condition: Fields of time or date-time types do not set default values or default values are empty.
Configurable: No
Supported Database Types: All