Note
This variable was introduced in OceanBase Database V2.1.
Description
foreign_key_checks specifies whether to enable FOREIGN KEY constraint check for DML or DDL statements.
Applicability
This variable is applicable to only OceanBase Database in MySQL mode.
Attributes
| Attribute | Description |
|---|---|
| Type | Boolean |
| Default value | 1 |
| Value range | 0: disables FOREIGN KEY constraint check.1: enables FOREIGN KEY constraint check. |
| Effective scope | |
| Modifiable | Yes. You can use the SET statement to modify the variable. |
Considerations
By default, OceanBase Database checks foreign keys. To disable or enable foreign key check, modify the tenant variable foreign_key_checks. If you do not specify the constraint name when you create a FOREIGN KEY constraint, the system automatically assigns a constraint name in the format of table name_OBFK_creation timestamp, such as t1_OBFK_1627747200000000.
Examples
Set the variable at the session level
obclient> SET foreign_key_checks = ON;or
obclient> SET foreign_key_checks = 1;Set the variable at the global level
obclient> SET GLOBAL foreign_key_checks = ON;or
obclient> SET GLOBAL foreign_key_checks = 1;