Updated on 2025-02-27 GMT+08:00

Constraint Design

DEFAULT and NULL Constraints

  • [Recommendation] If all the column values can be obtained from services, you are advised not to use the DEFAULT constraint. Otherwise, unexpected results will be generated during data loading.
  • [Recommendation] Add NOT NULL constraints to columns that never have NULL values. The optimizer automatically optimizes the columns in certain scenarios.
  • [Recommendation] Explicitly name all constraints excluding NOT NULL and DEFAULT.

Unique Constraints

  • [Description] Row-store tables support UNIQUE constraints.
  • [Recommendation] The constraint name should indicate that it is a unique constraint, for example, UNIIncluded columns.

Primary Key Constraints

  • [Description] Row-store tables support PRIMARY KEY constraints.
  • [Recommendation] The constraint name should indicate that it is a primary key constraint, for example, PKColumn name.

Check Constraints

  • [Description] Row-store tables support CHECK constraints.
  • [Recommendation] The constraint name should indicate that it is a check constraint, for example, CKColumn name.