Overview
Displays the metadata of foreign key constraints.
Columns
Field |
Type |
Nullable |
Description |
|---|---|---|---|
| CONSTRAINT_CATALOG | varchar(64) | NO | This value is always def. |
| CONSTRAINT_SCHEMA | varchar(128) | NO | Name of the database to which the constraint belongs |
| CONSTRAINT_NAME | varchar(128) | NO | Constraint name |
| UNIQUE_CONSTRAINT_CATALOG | varchar(64) | NO | This value is always def. |
| UNIQUE_CONSTRAINT_SCHEMA | varchar(128) | NO | The name of the database where the unique constraint or primary key referenced by the constraint is located. |
| UNIQUE_CONSTRAINT_NAME | varchar(128) | NO | The name of the unique constraint or primary key referenced by the constraint. |
| MATCH_OPTION | varchar(64) | NO | Constraints the value of the MATCH attribute. In this case, the only valid value is NONE. |
| UPDATE_RULE | varchar(64) | NO | Specifies the value of the ON UPDATE clause. Valid values: CASCADE, SET NULL, RESTRICT, and NO ACTION. |
| DELETE_RULE | varchar(64) | NO | Specifies the value of the ON DELETE attribute. Valid values: CASCADE, SET NULL, RESTRICT, and NO ACTION. |
| TABLE_NAME | varchar(256) | NO | Name of the subtable where the constraint is located |
| REFERENCED_TABLE_NAME | varchar(256) | NO | Name of the parent table referenced by the constraint |
Sample query
Query the metadata of foreign key constraints in table tbl4.
obclient [oceanbase]> SELECT * FROM information_schema.REFERENTIAL_CONSTRAINTS WHERE TABLE_NAME='tbl4';
The query result is as follows:
+--------------------+-------------------+----------------------------+---------------------------+--------------------------+------------------------+--------------+-------------+-------------+------------+-----------------------+
| CONSTRAINT_CATALOG | CONSTRAINT_SCHEMA | CONSTRAINT_NAME | UNIQUE_CONSTRAINT_CATALOG | UNIQUE_CONSTRAINT_SCHEMA | UNIQUE_CONSTRAINT_NAME | MATCH_OPTION | UPDATE_RULE | DELETE_RULE | TABLE_NAME | REFERENCED_TABLE_NAME |
+--------------------+-------------------+----------------------------+---------------------------+--------------------------+------------------------+--------------+-------------+-------------+------------+-----------------------+
| def | infotest | tbl4_OBFK_1736909788672362 | def | infotest | PRIMARY | NONE | CASCADE | RESTRICT | tbl4 | tbl2 |
+--------------------+-------------------+----------------------------+---------------------------+--------------------------+------------------------+--------------+-------------+-------------+------------+-----------------------+
1 row in set