From f886ade3eb700451ba5b268a3aed6eb2ba8c9feb Mon Sep 17 00:00:00 2001 From: Aolin Date: Wed, 20 Dec 2023 16:50:20 +0800 Subject: [PATCH] Add docs for the I_S keyword table Signed-off-by: Aolin --- TOC.md | 1 + .../information-schema-keywords.md | 43 +++++++++++++++++++ information-schema/information-schema.md | 1 + keywords.md | 2 + 4 files changed, 47 insertions(+) create mode 100644 information-schema/information-schema-keywords.md diff --git a/TOC.md b/TOC.md index 7e58ca26159c6..921a7e2465559 100644 --- a/TOC.md +++ b/TOC.md @@ -942,6 +942,7 @@ - [`INSPECTION_RESULT`](/information-schema/information-schema-inspection-result.md) - [`INSPECTION_RULES`](/information-schema/information-schema-inspection-rules.md) - [`INSPECTION_SUMMARY`](/information-schema/information-schema-inspection-summary.md) + - [`KEYWORDS`](/information-schema/information-schema-keywords.md) - [`KEY_COLUMN_USAGE`](/information-schema/information-schema-key-column-usage.md) - [`MEMORY_USAGE`](/information-schema/information-schema-memory-usage.md) - [`MEMORY_USAGE_OPS_HISTORY`](/information-schema/information-schema-memory-usage-ops-history.md) diff --git a/information-schema/information-schema-keywords.md b/information-schema/information-schema-keywords.md new file mode 100644 index 0000000000000..c43bb2b721c95 --- /dev/null +++ b/information-schema/information-schema-keywords.md @@ -0,0 +1,43 @@ +--- +title: KEYWORDS +summary: 了解 INFORMATION_SCHEMA 表 `KEYWORDS`。 +--- + +# KEYWORDS + +TiDB 从 v7.6.0 开始提供 `KEYWORDS` 表,你可以使用该表查看[关键字](/keywords.md)的信息。 + +```sql +USE INFORMATION_SCHEMA; +DESC keywords; +``` + +输出结果如下: + +``` ++----------+--------------+------+------+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++----------+--------------+------+------+---------+-------+ +| WORD | varchar(128) | YES | | NULL | | +| RESERVED | int(11) | YES | | NULL | | ++----------+--------------+------+------+---------+-------+ +2 rows in set (0.00 sec) +``` + +下面的 SQL 语句查询 `ADD` 和 `USER` 关键字的信息: + +```sql +SELECT * FROM keywords WHERE WORD IN ('ADD','USER'); +``` + +输出结果显示 `ADD` 是一个保留关键字,`USER` 是一个非保留关键字。 + +``` ++------+----------+ +| WORD | RESERVED | ++------+----------+ +| ADD | 1 | +| USER | 0 | ++------+----------+ +2 rows in set (0.00 sec) +``` diff --git a/information-schema/information-schema.md b/information-schema/information-schema.md index 340fff1308438..a5485df39e102 100644 --- a/information-schema/information-schema.md +++ b/information-schema/information-schema.md @@ -25,6 +25,7 @@ Information Schema 提供了一种查看系统元数据的 ANSI 标准方法。 | `FILES` | TiDB 未实现,返回零行。 | | `GLOBAL_STATUS` | TiDB 未实现,返回零行。 | | `GLOBAL_VARIABLES` | TiDB 未实现,返回零行。 | +| [`KEYWORDS`](/information-schema/information-schema-keywords.md) | 提供关键字列表。 | | [`KEY_COLUMN_USAGE`](/information-schema/information-schema-key-column-usage.md) | 描述列的键约束,例如主键约束。 | | `OPTIMIZER_TRACE` | TiDB 未实现,返回零行。 | | `PARAMETERS` | TiDB 未实现,返回零行。 | diff --git a/keywords.md b/keywords.md index 9e83477276d2b..bac07c4039f53 100644 --- a/keywords.md +++ b/keywords.md @@ -56,6 +56,8 @@ CREATE TABLE test.select (BEGIN int, END int); Query OK, 0 rows affected (0.08 sec) ``` +TiDB 从 v7.6.0 开始提供 [`INFORMATION_SCHEMA.KEYWORDS`](/information-schema/information-schema-keywords.md) 表,其中包含了所有关键字的信息。 + ## 关键字列表 下表列出了 TiDB 中所有的关键字。其中保留字用 `(R)` 来标识。[窗口函数](/functions-and-operators/window-functions.md)的保留字用 `(R-Window)` 来标识。需要用反引号 `` ` `` 包裹的特殊非保留字用 `(S)` 来标识。