Skip to content

Commit 89fb4ed

Browse files
authored
Add docs for information_schema.CHECK_CONSTRAINTS (#14780)
1 parent e9fbd3b commit 89fb4ed

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

TOC-tidb-cloud.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,7 @@
511511
- INFORMATION_SCHEMA
512512
- [Overview](/information-schema/information-schema.md)
513513
- [`ANALYZE_STATUS`](/information-schema/information-schema-analyze-status.md)
514+
- [`CHECK_CONSTRAINTS`](/information-schema/information-schema-check-constraints.md)
514515
- [`CLIENT_ERRORS_SUMMARY_BY_HOST`](/information-schema/client-errors-summary-by-host.md)
515516
- [`CLIENT_ERRORS_SUMMARY_BY_USER`](/information-schema/client-errors-summary-by-user.md)
516517
- [`CLIENT_ERRORS_SUMMARY_GLOBAL`](/information-schema/client-errors-summary-global.md)
@@ -616,4 +617,4 @@
616617
- [2021](/tidb-cloud/release-notes-2021.md)
617618
- [2020](/tidb-cloud/release-notes-2020.md)
618619
- Maintenance Notification
619-
- [[2023-08-31] TiDB Cloud Console Maintenance Notification](/tidb-cloud/notification-2023-08-31-console-maintenance.md)
620+
- [[2023-08-31] TiDB Cloud Console Maintenance Notification](/tidb-cloud/notification-2023-08-31-console-maintenance.md)

TOC.md

+1
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,7 @@
894894
- INFORMATION_SCHEMA
895895
- [Overview](/information-schema/information-schema.md)
896896
- [`ANALYZE_STATUS`](/information-schema/information-schema-analyze-status.md)
897+
- [`CHECK_CONSTRAINTS`](/information-schema/information-schema-check-constraints.md)
897898
- [`CLIENT_ERRORS_SUMMARY_BY_HOST`](/information-schema/client-errors-summary-by-host.md)
898899
- [`CLIENT_ERRORS_SUMMARY_BY_USER`](/information-schema/client-errors-summary-by-user.md)
899900
- [`CLIENT_ERRORS_SUMMARY_GLOBAL`](/information-schema/client-errors-summary-global.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
title: CHECK_CONSTRAINTS
3+
summary: Learn the `CHECK_CONSTRAINTS` INFORMATION_SCHEMA table.
4+
---
5+
6+
# CHECK\_CONSTRAINTS
7+
8+
The `CHECK_CONSTRAINTS` table provides information about [`CHECK` constraints](/constraints.md#check) on tables.
9+
10+
```sql
11+
USE INFORMATION_SCHEMA;
12+
DESC CHECK_CONSTRAINTS;
13+
```
14+
15+
The output is as follows:
16+
17+
```sql
18+
+--------------------+-------------+------+-----+---------+-------+
19+
| Field | Type | Null | Key | Default | Extra |
20+
+--------------------+-------------+------+-----+---------+-------+
21+
| CONSTRAINT_CATALOG | varchar(64) | NO | | NULL | |
22+
| CONSTRAINT_SCHEMA | varchar(64) | NO | | NULL | |
23+
| CONSTRAINT_NAME | varchar(64) | NO | | NULL | |
24+
| CHECK_CLAUSE | longtext | NO | | NULL | |
25+
+--------------------+-------------+------+-----+---------+-------+
26+
4 rows in set (0.00 sec)
27+
```
28+
29+
The following example adds a `CHECK` constraint using the `CREATE TABLE` statement:
30+
31+
```sql
32+
CREATE TABLE test.t1 (id INT PRIMARY KEY, CHECK (id%2 = 0));
33+
SELECT * FROM CHECK_CONSTRAINTS\G
34+
```
35+
36+
The output is as follows:
37+
38+
```sql
39+
*************************** 1. row ***************************
40+
CONSTRAINT_CATALOG: def
41+
CONSTRAINT_SCHEMA: test
42+
CONSTRAINT_NAME: t1_chk_1
43+
CHECK_CLAUSE: (`id` % 2 = 0)
44+
1 row in set (0.00 sec)
45+
```
46+
47+
Fields in the `CHECK_CONSTRAINTS` table are described as follows:
48+
49+
* `CONSTRAINT_CATALOG`: The catalog of the constraint, which is always `def`.
50+
* `CONSTRAINT_SCHEMA`: The schema of the constraint.
51+
* `CONSTRAINT_NAME`: The name of the constraint.
52+
* `CHECK_CLAUSE`: The clause of the check constraint.

0 commit comments

Comments
 (0)