Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions TOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
48 changes: 48 additions & 0 deletions information-schema/information-schema-keywords.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
title: KEYWORDS
summary: 了解 INFORMATION_SCHEMA 表 `KEYWORDS`。
---

# KEYWORDS

TiDB 从 v7.6.0 开始提供 `KEYWORDS` 表,你可以使用该表查看 TiDB 中[关键字](/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)
```

字段含义如下:

- `WORD`:关键字
- `RESERVED`:关键字是否为保留关键字

Comment thread
Oreoxmt marked this conversation as resolved.
例如,你可以使用以下 SQL 语句查询 `ADD` 和 `USER` 关键字的信息:

```sql
SELECT * FROM INFORMATION_SCHEMA.KEYWORDS WHERE WORD IN ('ADD','USER');
```

输出结果显示 `ADD` 是一个保留关键字,`USER` 是一个非保留关键字。

```
+------+----------+
| WORD | RESERVED |
+------+----------+
| ADD | 1 |
| USER | 0 |
+------+----------+
2 rows in set (0.00 sec)
```
1 change: 1 addition & 0 deletions information-schema/information-schema.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 未实现,返回零行。 |
Expand Down
2 changes: 2 additions & 0 deletions keywords.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 中所有的关键字。

## 关键字列表

下表列出了 TiDB 中所有的关键字。其中保留字用 `(R)` 来标识。[窗口函数](/functions-and-operators/window-functions.md)的保留字用 `(R-Window)` 来标识。需要用反引号 `` ` `` 包裹的特殊非保留字用 `(S)` 来标识。
Expand Down