Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ebnf show errors #17025

Merged
merged 1 commit into from
Apr 8, 2024
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
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 @@ -14,22 +14,24 @@ aliases: ['/docs-cn/dev/sql-statements/sql-statement-show-collation/','/docs-cn/

## 语法图

**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 @@ -44,14 +46,11 @@ SHOW COLLATION;

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

{{< copyable "sql" >}}

```sql

SHOW COLLATION;
```

```
```sql
+--------------------+---------+------+---------+----------+---------+
| Collation | Charset | Id | Default | Compiled | Sortlen |
+--------------------+---------+------+---------+----------+---------+
Expand All @@ -70,6 +69,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 @@ -12,9 +12,14 @@ aliases: ['/docs-cn/dev/sql-statements/sql-statement-show-errors/','/docs-cn/dev

## 语法图

**ShowErrorsStmt:**
```ebnf+diagram
ShowErrorsStmt ::=
"SHOW" "ERRORS" ShowLikeOrWhere?

![ShowErrorsStmt](/media/sqlgram/ShowErrorsStmt.png)
ShowLikeOrWhere ::=
"LIKE" SimpleExpr
| "WHERE" Expression
```

## 示例

Expand Down
Loading