Note
This view is introduced since OceanBase Database V2.2.77.
Purpose
This view displays metadata of foreign key constraints.
Columns
| Column | Type | Nullable? | Description |
|---|---|---|---|
| CONSTRAINT_CATALOG | varchar(64) | NO | The name of the catalog to which the constraint belongs. The value of this column is always def. |
| CONSTRAINT_SCHEMA | varchar(128) | NO | The name of the database to which the constraint belongs. |
| CONSTRAINT_NAME | varchar(128) | NO | The name of the constraint. |
| UNIQUE_CONSTRAINT_CATALOG | varchar(64) | NO | The name of the catalog containing the unique constraint that the constraint references. The value of this column is always def. |
| UNIQUE_CONSTRAINT_SCHEMA | varchar(128) | NO | The name of the database containing the unique constraint or primary key that the constraint references. |
| UNIQUE_CONSTRAINT_NAME | varchar(128) | NO | The name of the unique constraint or primary key that the constraint references. |
| MATCH_OPTION | varchar(64) | NO | The value of the constraint MATCH attribute. The only valid value at this time is NON. |
| UPDATE_RULE | varchar(64) | NO | The value of the constraint ON UPDATE attribute. The possible values are CASCADE, SET NULL, RESTRICT, and NO ACTION. |
| DELETE_RULE | varchar(64) | NO | The value of the constraint ON DELETE attribute. The possible values are CASCADE, SET NULL, RESTRICT, and NO ACTION. |
| TABLE_NAME | varchar(256) | NO | The name of the child table containing the constraint. |
| REFERENCED_TABLE_NAME | varchar(256) | NO | The name of the parent table referenced by the constraint. |
Sample query
Query the metadata information 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