TABLE_CONSTRAINTS
The TABLE_CONSTRAINTS
table describes which tables have constraints.
DESC INFORMATION_SCHEMA.table_constraints;
+--------------------+--------+------+------+---------+---------------+
| Column | Type | Key | Null | Default | Semantic Type |
+--------------------+--------+------+------+---------+---------------+
| constraint_catalog | String | | NO | | FIELD |
| constraint_schema | String | | NO | | FIELD |
| constraint_name | String | | NO | | FIELD |
| table_schema | String | | NO | | FIELD |
| table_name | String | | NO | | FIELD |
| constraint_type | String | | NO | | FIELD |
| enforced | String | | NO | | FIELD |
+--------------------+--------+------+------+---------+---------------+
The columns in the table:
CONSTRAINT_CATALOG
: The name of the catalog to which the constraint belongs. This value is alwaysdef
.CONSTRAINT_SCHEMA
: The name of the database to which the constraint belongs.CONSTRAINT_NAME
: The name of the constraint,TIME INDEX
orPRIMARY
.TABLE_NAME
: The name of the table.CONSTRAINT_TYPE
: The type of the constraint. The value can beTIME INDEX
orPRIMARY KEY
. TheTIME INDEX
andPRIMARY KEY
information is similar to the execution result of theSHOW INDEX
statement.enforced
: Doesn’t supportCHECK
constraints, the value is alwaysYES
.
select * from INFORMATION_SCHEMA.table_constraints WHERE table_name = 'monitor'\G;
The output:
*************************** 1. row ***************************
constraint_catalog: def
constraint_schema: public
constraint_name: TIME INDEX
table_schema: public
table_name: monitor
constraint_type: TIME INDEX
enforced: YES
*************************** 2. row ***************************
constraint_catalog: def
constraint_schema: public
constraint_name: PRIMARY
table_schema: public
table_name: monitor
constraint_type: PRIMARY KEY
enforced: YES
当前内容版权归 GreptimeDB 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 GreptimeDB .