From 8f7181ec44f34f1fd95855155a0d9033b3f5180c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Mon, 8 Apr 2024 11:31:33 +0200 Subject: [PATCH 1/2] ebnf show charset --- .../sql-statement-show-character-set.md | 46 ++++++++++++++++--- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/sql-statements/sql-statement-show-character-set.md b/sql-statements/sql-statement-show-character-set.md index aace1b7bb1d59..09488da6bc95c 100644 --- a/sql-statements/sql-statement-show-character-set.md +++ b/sql-statements/sql-statement-show-character-set.md @@ -9,18 +9,22 @@ This statement provides a static list of available character sets in TiDB. The o ## Synopsis -**ShowCharsetStmt:** +```ebnf+diagram +ShowCharsetStmt ::= + "SHOW" ( ("CHARACTER" | "CHAR") | "CHARSET" ) ShowLikeOrWhere? -![ShowCharsetStmt](/media/sqlgram/ShowCharsetStmt.png) - -**CharsetKw:** - -![CharsetKw](/media/sqlgram/CharsetKw.png) +ShowLikeOrWhere ::= + "LIKE" SimpleExpr +| "WHERE" Expression +``` ## Examples ```sql -mysql> SHOW CHARACTER SET; +SHOW CHARACTER SET; +``` + +``` +---------+---------------+-------------------+--------+ | Charset | Description | Default collation | Maxlen | +---------+---------------+-------------------+--------+ @@ -33,6 +37,34 @@ mysql> SHOW CHARACTER SET; 5 rows in set (0.00 sec) ``` +```sql +SHOW CHARACTER SET LIKE 'utf8%'; +``` + +``` ++---------+---------------+-------------------+--------+ +| Charset | Description | Default collation | Maxlen | ++---------+---------------+-------------------+--------+ +| utf8 | UTF-8 Unicode | utf8_bin | 3 | +| utf8mb4 | UTF-8 Unicode | utf8mb4_bin | 4 | ++---------+---------------+-------------------+--------+ +2 rows in set (0.00 sec) +``` + +```sql +SHOW CHARACTER SET WHERE Description='UTF-8 Unicode'; +``` + +``` ++---------+---------------+-------------------+--------+ +| Charset | Description | Default collation | Maxlen | ++---------+---------------+-------------------+--------+ +| utf8 | UTF-8 Unicode | utf8_bin | 3 | +| utf8mb4 | UTF-8 Unicode | utf8mb4_bin | 4 | ++---------+---------------+-------------------+--------+ +2 rows in set (0.00 sec) +``` + ## MySQL compatibility The usage of `SHOW CHARACTER SET` statement in TiDB is fully compatible with MySQL. However, charsets in TiDB might have different default collations compared with MySQL. For details, refer to [Compatibility with MySQL](/mysql-compatibility.md). If you find any compatibility differences, [report a bug](https://docs.pingcap.com/tidb/stable/support). From a71ff9c19ccbe1902e5bd7b469cfe8fa18de7584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Tue, 9 Apr 2024 08:07:52 +0200 Subject: [PATCH 2/2] Update sql-statements/sql-statement-show-character-set.md Co-authored-by: kennytm --- sql-statements/sql-statement-show-character-set.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-show-character-set.md b/sql-statements/sql-statement-show-character-set.md index 09488da6bc95c..69fd25eb48e57 100644 --- a/sql-statements/sql-statement-show-character-set.md +++ b/sql-statements/sql-statement-show-character-set.md @@ -11,7 +11,7 @@ This statement provides a static list of available character sets in TiDB. The o ```ebnf+diagram ShowCharsetStmt ::= - "SHOW" ( ("CHARACTER" | "CHAR") | "CHARSET" ) ShowLikeOrWhere? + "SHOW" ( ("CHARACTER" | "CHAR") "SET" | "CHARSET" ) ShowLikeOrWhere? ShowLikeOrWhere ::= "LIKE" SimpleExpr