Skip to content

Commit

Permalink
ebnf show errors (#17025) (#17028)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Apr 8, 2024
1 parent 7b94edf commit 2a303ff
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
38 changes: 28 additions & 10 deletions sql-statements/sql-statement-show-collation.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,24 @@ summary: TiDB 数据库中 SHOW COLLATION 的使用概况。
## 语法图

**ShowCollationStmt:**
```ebnf+diagram
ShowCollationStmt ::=
"SHOW" "COLLATION" ShowLikeOrWhere?
![ShowCollationStmt](/media/sqlgram/ShowCollationStmt.png)
ShowLikeOrWhere ::=
"LIKE" SimpleExpr
| "WHERE" Expression
```

## 示例

若未开启新排序规则框架,仅展示二进制排序规则:

{{< copyable "sql" >}}

```sql

SHOW COLLATION;
```

```
```sql
+-------------+---------+------+---------+----------+---------+
| Collation | Charset | Id | Default | Compiled | Sortlen |
+-------------+---------+------+---------+----------+---------+
Expand All @@ -43,14 +45,11 @@ SHOW COLLATION;

若开启了新排序规则框架,则在二进制排序规则之外,额外支持 `utf8_general_ci``utf8mb4_general_ci` 两种大小写和口音不敏感的排序规则:

{{< copyable "sql" >}}

```sql

SHOW COLLATION;
```

```
```sql
+--------------------+---------+------+---------+----------+---------+
| Collation | Charset | Id | Default | Compiled | Sortlen |
+--------------------+---------+------+---------+----------+---------+
Expand All @@ -69,6 +68,25 @@ SHOW COLLATION;
11 rows in set (0.001 sec)
```

要过滤字符集,可以添加 `WHERE` 子句。

```sql
SHOW COLLATION WHERE Charset="utf8mb4";
```

```sql
+--------------------+---------+-----+---------+----------+---------+
| Collation | Charset | Id | Default | Compiled | Sortlen |
+--------------------+---------+-----+---------+----------+---------+
| utf8mb4_0900_ai_ci | utf8mb4 | 255 | | Yes | 1 |
| utf8mb4_0900_bin | utf8mb4 | 309 | | Yes | 1 |
| utf8mb4_bin | utf8mb4 | 46 | Yes | Yes | 1 |
| utf8mb4_general_ci | utf8mb4 | 45 | | Yes | 1 |
| utf8mb4_unicode_ci | utf8mb4 | 224 | | Yes | 1 |
+--------------------+---------+-----+---------+----------+---------+
5 rows in set (0.00 sec)
```

## MySQL 兼容性

`SHOW COLLATION` 语句功能与 MySQL 完全兼容。注意,TiDB 中字符集的默认排序规则与 MySQL 有所不同,具体可参考[与 MySQL 兼容性对比](/mysql-compatibility.md#默认设置)。如发现任何其他兼容性差异,请尝试 [TiDB 支持资源](/support.md)
Expand Down
9 changes: 7 additions & 2 deletions sql-statements/sql-statement-show-errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@ summary: TiDB 数据库中 SHOW ERRORS 的使用概况。

## 语法图

**ShowErrorsStmt:**
```ebnf+diagram
ShowErrorsStmt ::=
"SHOW" "ERRORS" ShowLikeOrWhere?
![ShowErrorsStmt](/media/sqlgram/ShowErrorsStmt.png)
ShowLikeOrWhere ::=
"LIKE" SimpleExpr
| "WHERE" Expression
```

## 示例

Expand Down

0 comments on commit 2a303ff

Please sign in to comment.