diff --git a/TOC-tidb-cloud.md b/TOC-tidb-cloud.md index c3b69b7a58aac..70609d8455afe 100644 --- a/TOC-tidb-cloud.md +++ b/TOC-tidb-cloud.md @@ -543,6 +543,7 @@ - [`DDL_JOBS`](/information-schema/information-schema-ddl-jobs.md) - [`DEADLOCKS`](/information-schema/information-schema-deadlocks.md) - [`ENGINES`](/information-schema/information-schema-engines.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/TOC.md b/TOC.md index 671f3117e9fba..269eabe06c9b8 100644 --- a/TOC.md +++ b/TOC.md @@ -927,6 +927,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..1c2668b2275bf --- /dev/null +++ b/information-schema/information-schema-keywords.md @@ -0,0 +1,48 @@ +--- +title: KEYWORDS +summary: Learn the `KEYWORDS` INFORMATION_SCHEMA table. +--- + +# KEYWORDS + +Starting from v7.6.0, TiDB provides the `KEYWORDS` table. You can use this table to get information about [keywords](/keywords.md) in TiDB. + +```sql +USE INFORMATION_SCHEMA; +DESC keywords; +``` + +The output is as follows: + +``` ++----------+--------------+------+------+---------+-------+ +| Field | Type | Null | Key | Default | Extra | ++----------+--------------+------+------+---------+-------+ +| WORD | varchar(128) | YES | | NULL | | +| RESERVED | int(11) | YES | | NULL | | ++----------+--------------+------+------+---------+-------+ +2 rows in set (0.00 sec) +``` + +Field description: + +- `WORD`: The keyword. +- `RESERVED`: Whether the keyword is reserved. + +The following statement queries the information about `ADD` and `USER` keywords: + +```sql +SELECT * FROM INFORMATION_SCHEMA.KEYWORDS WHERE WORD IN ('ADD','USER'); +``` + +From the output, you can see that `ADD` is a reserved keyword and `USER` is a non-reserved keyword. + +``` ++------+----------+ +| 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 4994d48ba4319..9afd5684c5624 100644 --- a/information-schema/information-schema.md +++ b/information-schema/information-schema.md @@ -28,6 +28,7 @@ Many `INFORMATION_SCHEMA` tables have a corresponding `SHOW` command. The benefi | `FILES` | Not implemented by TiDB. Returns zero rows. | | `GLOBAL_STATUS` | Not implemented by TiDB. Returns zero rows. | | `GLOBAL_VARIABLES` | Not implemented by TiDB. Returns zero rows. | +| [`KEYWORDS`](/information-schema/information-schema-keywords.md) | Provides a full list of keywords. | | [`KEY_COLUMN_USAGE`](/information-schema/information-schema-key-column-usage.md) | Describes the key constraints of the columns, such as the primary key constraint. | | `OPTIMIZER_TRACE` | Not implemented by TiDB. Returns zero rows. | | `PARAMETERS` | Not implemented by TiDB. Returns zero rows. | diff --git a/keywords.md b/keywords.md index 3f3fd9886ac20..29bf539dbb565 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) ``` +Starting from v7.6.0, TiDB provides a full list of keywords in the [`INFORMATION_SCHEMA.KEYWORDS`](/information-schema/information-schema-keywords.md) table. + ## Keyword list The following list shows the keywords in TiDB. Reserved keywords are marked with `(R)`. Reserved keywords for [Window Functions](/functions-and-operators/window-functions.md) are marked with `(R-Window)`. Special non-reserved keywords that need to be escaped with backticks `` ` `` are marked with `(S)`.