Skip to content

Commit

Permalink
ebnf: show bindings, show databases, show privileges, show config (#1…
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored Apr 18, 2024
1 parent 558a493 commit b56d762
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 51 deletions.
29 changes: 7 additions & 22 deletions sql-statements/sql-statement-show-bindings.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,17 @@ summary: TiDB 数据库中 SHOW [GLOBAL|SESSION] BINDINGS 的使用概况。

## 语法图

**ShowStmt:**
```ebnf+diagram
ShowBindingsStmt ::=
"SHOW" ("GLOBAL" | "SESSION")? "BINDINGS" ShowLikeOrWhere?
![ShowStmt](/media/sqlgram/ShowStmt.png)

**ShowTargetFilterable:**

![ShowTargetFilterable](/media/sqlgram/ShowTargetFilterable.png)

**GlobalScope:**

![GlobalScope](/media/sqlgram/GlobalScope.png)

**ShowLikeOrWhereOpt**

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

## 语法说明

{{< copyable "sql" >}}

```sql
SHOW [GLOBAL | SESSION] BINDINGS [ShowLikeOrWhereOpt];
```

该语句会输出 GLOBAL 或者 SESSION 作用域内的执行计划绑定,在不指定作用域时默认作用域为 SESSION。目前 `SHOW BINDINGS` 会输出 8 列,具体如下:

| 列名 | 说明 |
Expand All @@ -49,8 +36,6 @@ SHOW [GLOBAL | SESSION] BINDINGS [ShowLikeOrWhereOpt];

## 示例

{{< copyable "sql" >}}

```sql
CREATE TABLE t1 (
id INT NOT NULL PRIMARY KEY auto_increment,
Expand Down
19 changes: 7 additions & 12 deletions sql-statements/sql-statement-show-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,19 @@ summary: TiDB 数据库中 SHOW CONFIG 的使用概况。

## 语法图

**ShowStmt:**
```ebnf+diagram
ShowConfigStmt ::=
"SHOW" "CONFIG" ShowLikeOrWhere?
![ShowStmt](/media/sqlgram/ShowStmt.png)

**ShowTargetFilterable:**

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

## 示例

显示所有配置:

{{< copyable "sql" >}}

```sql
SHOW CONFIG;
```
Expand All @@ -40,8 +39,6 @@ SHOW CONFIG;

显示 `type``tidb` 的配置:

{{< copyable "sql" >}}

```sql
SHOW CONFIG WHERE type = 'tidb' AND name = 'advertise-address';
```
Expand All @@ -57,8 +54,6 @@ SHOW CONFIG WHERE type = 'tidb' AND name = 'advertise-address';

也可以用 `LIKE` 子句来显示 `type``tidb` 的配置:

{{< copyable "sql" >}}

```sql
SHOW CONFIG LIKE 'tidb';
```
Expand Down
18 changes: 8 additions & 10 deletions sql-statements/sql-statement-show-databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,17 @@ summary: TiDB 数据库中 SHOW DATABASES 的使用概况。

**ShowDatabasesStmt:**

![ShowDatabasesStmt](/media/sqlgram/ShowDatabasesStmt.png)
```ebnf+diagram
ShowDatabasesStmt ::=
"SHOW" "DATABASES" ShowLikeOrWhere?
**ShowLikeOrWhereOpt:**

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

## 示例

{{< copyable "sql" >}}

```sql
SHOW DATABASES;
```
Expand All @@ -39,8 +40,6 @@ SHOW DATABASES;
4 rows in set (0.00 sec)
```

{{< copyable "sql" >}}

```sql
CREATE DATABASE mynewdb;
```
Expand All @@ -49,8 +48,6 @@ CREATE DATABASE mynewdb;
Query OK, 0 rows affected (0.10 sec)
```

{{< copyable "sql" >}}

```sql
SHOW DATABASES;
```
Expand All @@ -77,3 +74,4 @@ SHOW DATABASES;
* [SHOW SCHEMAS](/sql-statements/sql-statement-show-schemas.md)
* [DROP DATABASE](/sql-statements/sql-statement-drop-database.md)
* [CREATE DATABASE](/sql-statements/sql-statement-create-database.md)
* [`INFORMATION_SCHEMA.SCHEMATA`](/information-schema/information-schema-schemata.md)
13 changes: 6 additions & 7 deletions sql-statements/sql-statement-show-privileges.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@ summary: TiDB 数据库中 SHOW PRIVILEGES 的使用概况。

## 语法图

**ShowStmt:**

![ShowStmt](/media/sqlgram/ShowStmt.png)
```ebnf+diagram
ShowPrivilegesStmt ::=
"SHOW" "PRIVILEGES"
```

## 示例

{{< copyable "sql" >}}

```sql
show privileges;
SHOW PRIVILEGES;
```

```sql
mysql> show privileges;
+---------------------------------+---------------------------------------+-------------------------------------------------------+
| Privilege | Context | Comment |
+---------------------------------+---------------------------------------+-------------------------------------------------------+
Expand Down Expand Up @@ -86,4 +84,5 @@ mysql> show privileges;
## 另请参阅

* [SHOW GRANTS](/sql-statements/sql-statement-show-grants.md)
* [权限管理](/privilege-management.md)
* [`GRANT <privileges>`](/sql-statements/sql-statement-grant-privileges.md)

0 comments on commit b56d762

Please sign in to comment.