OceanBase Database supports multiple types of integrity constraints.
You can use the following types of integrity constraints to constrain the input column values:
NOT NULLintegrity constraintsUNIQUE KEYintegrity constraintsPRIMARY KEYintegrity constraintsReferential integrity constraints
NOT NULL integrity constraints
This type of integrity constraints applies a null rule that is defined on a specific column. This rule disallows the inserts or updates of rows that contain a NULL in that column.
UNIQUE KEY integrity constraints
This type of integrity constraints applies a unique value rule that is defined on a specific column or column set. This rule allows the inserts or updates of rows only if the rows contain a unique value in the specific column or column set.
PRIMARY KEY integrity constraints
This type of integrity constraints applies a primary key value rule that is defined on a specific key. The key can be a column or column set. This rule ensures that each row in a table can be uniquely identified by the values of the key.
Referential integrity constraints
This type of integrity constraints applies a referential integrity rule that is defined on a specific key in one table. The key can be a column or column set. This rule ensures that the values of the key match the key values, or the referenced values, in a related table.
When using a referential integrity constraint, you must also follow some rules that determine which types of data manipulation are allowed on referenced values and how these operations affect dependent values. The following are the rules:
Restrict: Referenced values cannot be updated or deleted.
Set to Null: If a referenced value is updated or deleted, all associated dependent values are set to
NULL.Set to Default: If a referenced value is updated or deleted, all associated dependent values are set to a default value.
Cascade: If a referenced value is updated, all associated dependent values are updated to the same value as this referenced value. If a referenced row is deleted, all associated dependent rows are deleted.
No Action: Referenced values cannot be updated or deleted. In contrast to the
RESTRICTrule, this rule is checked only when the statement ends. If the constraint is deferred, this rule is checked when the transaction ends.