Note
This variable is introduced since 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 valid only in the MySQL mode of OceanBase Database.
Attributes
| Attribute | Description |
|---|---|
| Type | Boolean |
| Default value | 1 |
| Value range | 0: disables FOREIGN KEY constraint check.1: enables FOREIGN KEY constraint check. |
| Applicable scope | |
| Modifiable | Yes. It can be modified using the SET statement. |
Considerations
Foreign key constraint check is enabled in OceanBase Database by default. This check is controlled by the tenant variable foreign_key_checks. When you create a foreign key constraint without specifying a name, the system automatically allocates a constraint name with the table name, _OBFK_, and creation timestamp. For example, t1_OBFK_1627747200000000.
Examples
Session level
obclient> SET foreign_key_checks = ON;or
obclient> SET foreign_key_checks = 1;Global level
obclient> SET GLOBAL foreign_key_checks = ON;or
obclient> SET GLOBAL foreign_key_checks = 1;