From 22a64a737aa654a4c8cc5bd061cf5e48c0d8d72c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Fri, 8 Sep 2023 10:29:15 +0200 Subject: [PATCH 1/5] Add cos for information_scema.CHECK_CONSTRAINTS --- TOC-tidb-cloud.md | 3 +- TOC.md | 1 + .../information-schema-check-constraints.md | 43 +++++++++++++++++++ 3 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 information-schema/information-schema-check-constraints.md diff --git a/TOC-tidb-cloud.md b/TOC-tidb-cloud.md index 2741a8f699d08..9b210e5b84de0 100644 --- a/TOC-tidb-cloud.md +++ b/TOC-tidb-cloud.md @@ -506,6 +506,7 @@ - INFORMATION_SCHEMA - [Overview](/information-schema/information-schema.md) - [`ANALYZE_STATUS`](/information-schema/information-schema-analyze-status.md) + - [`CHECK_CONSTRAINTS`](/information-schema/information-schema-check-constraints.md) - [`CLIENT_ERRORS_SUMMARY_BY_HOST`](/information-schema/client-errors-summary-by-host.md) - [`CLIENT_ERRORS_SUMMARY_BY_USER`](/information-schema/client-errors-summary-by-user.md) - [`CLIENT_ERRORS_SUMMARY_GLOBAL`](/information-schema/client-errors-summary-global.md) @@ -611,4 +612,4 @@ - [2021](/tidb-cloud/release-notes-2021.md) - [2020](/tidb-cloud/release-notes-2020.md) - Maintenance Notification - - [[2023-08-31] TiDB Cloud Console Maintenance Notification](/tidb-cloud/notification-2023-08-31-console-maintenance.md) \ No newline at end of file + - [[2023-08-31] TiDB Cloud Console Maintenance Notification](/tidb-cloud/notification-2023-08-31-console-maintenance.md) diff --git a/TOC.md b/TOC.md index 6c967681da3af..149235be19e67 100644 --- a/TOC.md +++ b/TOC.md @@ -887,6 +887,7 @@ - INFORMATION_SCHEMA - [Overview](/information-schema/information-schema.md) - [`ANALYZE_STATUS`](/information-schema/information-schema-analyze-status.md) + - [`CHECK_CONSTRAINTS`](/information-schema/information-schema-check-constraints.md) - [`CLIENT_ERRORS_SUMMARY_BY_HOST`](/information-schema/client-errors-summary-by-host.md) - [`CLIENT_ERRORS_SUMMARY_BY_USER`](/information-schema/client-errors-summary-by-user.md) - [`CLIENT_ERRORS_SUMMARY_GLOBAL`](/information-schema/client-errors-summary-global.md) diff --git a/information-schema/information-schema-check-constraints.md b/information-schema/information-schema-check-constraints.md new file mode 100644 index 0000000000000..a2decca3e3f5c --- /dev/null +++ b/information-schema/information-schema-check-constraints.md @@ -0,0 +1,43 @@ +--- +title: CHECK_CONSTRAINTS +summary: Learn the `CHECK_CONSTRAINTS` INFORMATION_SCHEMA table. +--- + +# CHECK\_CONSTRAINTS + +The `CHECK_CONSTRAINTS` table provides information about [`CHECK` constraints](/constraints.md#CHECK) on tables. + +```sql +USE INFORMATION_SCHEMA; +DESC CHECK_CONSTRAINTS; +``` + +The output is as follows: + +```sql ++--------------------+-------------+------+-----+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++--------------------+-------------+------+-----+---------+-------+ +| CONSTRAINT_CATALOG | varchar(64) | NO | | NULL | | +| CONSTRAINT_SCHEMA | varchar(64) | NO | | NULL | | +| CONSTRAINT_NAME | varchar(64) | NO | | NULL | | +| CHECK_CLAUSE | longtext | NO | | NULL | | ++--------------------+-------------+------+-----+---------+-------+ +4 rows in set (0.00 sec) +``` + +```sql +CREATE TABLE test.t1 (id INT PRIMARY KEY, CHECK (id%2 = 0)); +SELECT * FROM CHECK_CONSTRAINTS\G +``` + +The output is as follows: + +```sql +*************************** 1. row *************************** +CONSTRAINT_CATALOG: def + CONSTRAINT_SCHEMA: test + CONSTRAINT_NAME: t1_chk_1 + CHECK_CLAUSE: (`id` % 2 = 0) +1 row in set (0.00 sec) +``` From 9d9fda057f7227045bf779d386a3381faca0ffc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Fri, 8 Sep 2023 10:46:35 +0200 Subject: [PATCH 2/5] Update achor name --- information-schema/information-schema-check-constraints.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/information-schema/information-schema-check-constraints.md b/information-schema/information-schema-check-constraints.md index a2decca3e3f5c..ec2b14b448067 100644 --- a/information-schema/information-schema-check-constraints.md +++ b/information-schema/information-schema-check-constraints.md @@ -5,7 +5,7 @@ summary: Learn the `CHECK_CONSTRAINTS` INFORMATION_SCHEMA table. # CHECK\_CONSTRAINTS -The `CHECK_CONSTRAINTS` table provides information about [`CHECK` constraints](/constraints.md#CHECK) on tables. +The `CHECK_CONSTRAINTS` table provides information about [`CHECK` constraints](/constraints.md#check) on tables. ```sql USE INFORMATION_SCHEMA; From fdbeb1aae5b5aa83bcc5ff7abb489c888fc11240 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Thu, 28 Sep 2023 08:13:08 +0200 Subject: [PATCH 3/5] Apply suggestions from code review Co-authored-by: Aolin --- .../information-schema-check-constraints.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/information-schema/information-schema-check-constraints.md b/information-schema/information-schema-check-constraints.md index ec2b14b448067..98ddd8a9a1f1b 100644 --- a/information-schema/information-schema-check-constraints.md +++ b/information-schema/information-schema-check-constraints.md @@ -26,6 +26,8 @@ The output is as follows: 4 rows in set (0.00 sec) ``` +The following example adds a `CHECK` constraint using the `CREATE TABLE` statement: + ```sql CREATE TABLE test.t1 (id INT PRIMARY KEY, CHECK (id%2 = 0)); SELECT * FROM CHECK_CONSTRAINTS\G @@ -41,3 +43,10 @@ CONSTRAINT_CATALOG: def CHECK_CLAUSE: (`id` % 2 = 0) 1 row in set (0.00 sec) ``` + +Fields in the `CHECK_CONSTRAINTS` table are described as follows: + +* `CONSTRAINT_CATALOG`: +* `CONSTRAINT_SCHEMA`: +* `CONSTRAINT_NAME`: +* `CHECK_CLAUSE`: From 0bbc2908af979bca184e2f5e04d74a60a6023e4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Thu, 28 Sep 2023 08:15:05 +0200 Subject: [PATCH 4/5] update --- .../information-schema-check-constraints.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/information-schema/information-schema-check-constraints.md b/information-schema/information-schema-check-constraints.md index 98ddd8a9a1f1b..51e8f58eea2ff 100644 --- a/information-schema/information-schema-check-constraints.md +++ b/information-schema/information-schema-check-constraints.md @@ -46,7 +46,7 @@ CONSTRAINT_CATALOG: def Fields in the `CHECK_CONSTRAINTS` table are described as follows: -* `CONSTRAINT_CATALOG`: -* `CONSTRAINT_SCHEMA`: -* `CONSTRAINT_NAME`: -* `CHECK_CLAUSE`: +* `CONSTRAINT_CATALOG`: The catalog of the constraint, always `def`. +* `CONSTRAINT_SCHEMA`: The schema of the constraint. +* `CONSTRAINT_NAME`: The name of the constraint. +* `CHECK_CLAUSE`: The clause of the check constraint. From 07159bd28ccaade5c31fda50e2eeaee93931b545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Thu, 28 Sep 2023 10:11:59 +0200 Subject: [PATCH 5/5] Update information-schema/information-schema-check-constraints.md Co-authored-by: Aolin --- information-schema/information-schema-check-constraints.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/information-schema/information-schema-check-constraints.md b/information-schema/information-schema-check-constraints.md index 51e8f58eea2ff..9b1a2088ac47a 100644 --- a/information-schema/information-schema-check-constraints.md +++ b/information-schema/information-schema-check-constraints.md @@ -46,7 +46,7 @@ CONSTRAINT_CATALOG: def Fields in the `CHECK_CONSTRAINTS` table are described as follows: -* `CONSTRAINT_CATALOG`: The catalog of the constraint, always `def`. +* `CONSTRAINT_CATALOG`: The catalog of the constraint, which is always `def`. * `CONSTRAINT_SCHEMA`: The schema of the constraint. * `CONSTRAINT_NAME`: The name of the constraint. * `CHECK_CLAUSE`: The clause of the check constraint.