From eafbfbc6fb5d9530cb81e2c3ea539096c6a05596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Tue, 9 Apr 2024 18:08:37 +0200 Subject: [PATCH 1/3] ebnf show columns from --- .../sql-statement-show-columns-from.md | 62 +++++-------------- 1 file changed, 17 insertions(+), 45 deletions(-) diff --git a/sql-statements/sql-statement-show-columns-from.md b/sql-statements/sql-statement-show-columns-from.md index eef35f39bf7db..6fd32cb41ba4f 100644 --- a/sql-statements/sql-statement-show-columns-from.md +++ b/sql-statements/sql-statement-show-columns-from.md @@ -16,53 +16,25 @@ The statements `SHOW [FULL] FIELDS FROM `, `DESC `, `DES ## Synopsis -**ShowStmt:** +```ebnf+diagram +ShowColumnsFromStmt ::= + "SHOW" "FULL"? ("COLUMNS" | "FIELDS") ("FROM" | "IN") TableName ("FROM" | "IN" SchemaName)? ShowLikeOrWhereOpt? -![ShowStmt](/media/sqlgram/ShowStmt.png) +TableName ::= + (Identifier ".")? Identifier -**ShowColumnsFilterable:** - -![ShowColumnsFilterable](/media/sqlgram/ShowColumnsFilterable.png) - -**OptFull:** - -![OptFull](/media/sqlgram/OptFull.png) - -**FieldsOrColumns:** - -![FieldsOrColumns](/media/sqlgram/FieldsOrColumns.png) - -**ShowTableAliasOpt:** - -![ShowTableAliasOpt](/media/sqlgram/ShowTableAliasOpt.png) - -**FromOrIn:** - -![FromOrIn](/media/sqlgram/FromOrIn.png) - -**TableName:** - -![TableName](/media/sqlgram/TableName.png) - -**ShowDatabaseNameOpt:** - -![ShowDatabaseNameOpt](/media/sqlgram/ShowDatabaseNameOpt.png) - -**DBName:** - -![DBName](/media/sqlgram/DBName.png) - -**ShowLikeOrWhereOpt:** - -![ShowLikeOrWhereOpt](/media/sqlgram/ShowLikeOrWhereOpt.png) +ShowLikeOrWhereOpt ::= + "LIKE" SimpleExpr +| "WHERE" Expression +``` ## Examples ```sql -mysql> create view v1 as select 1; +mysql> CREATE VIEW v1 AS SELECT 1; Query OK, 0 rows affected (0.11 sec) -mysql> show columns from v1; +mysql> SHOW COLUMNS FROM v1; +-------+-----------+------+------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-----------+------+------+---------+-------+ @@ -70,7 +42,7 @@ mysql> show columns from v1; +-------+-----------+------+------+---------+-------+ 1 row in set (0.00 sec) -mysql> desc v1; +mysql> DESC v1; +-------+-----------+------+------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-----------+------+------+---------+-------+ @@ -78,7 +50,7 @@ mysql> desc v1; +-------+-----------+------+------+---------+-------+ 1 row in set (0.00 sec) -mysql> describe v1; +mysql> DESCRIBE v1; +-------+-----------+------+------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-----------+------+------+---------+-------+ @@ -86,7 +58,7 @@ mysql> describe v1; +-------+-----------+------+------+---------+-------+ 1 row in set (0.00 sec) -mysql> explain v1; +mysql> EXPLAIN v1; +-------+-----------+------+------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-----------+------+------+---------+-------+ @@ -94,7 +66,7 @@ mysql> explain v1; +-------+-----------+------+------+---------+-------+ 1 row in set (0.00 sec) -mysql> show fields from v1; +mysql> SHOW FIELDS FROM v1; +-------+-----------+------+------+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-----------+------+------+---------+-------+ @@ -102,7 +74,7 @@ mysql> show fields from v1; +-------+-----------+------+------+---------+-------+ 1 row in set (0.00 sec) -mysql> show full columns from v1; +mysql> SHOW FULL COLUMNS FROM v1; +-------+-----------+-----------+------+------+---------+-------+---------------------------------+---------+ | Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment | +-------+-----------+-----------+------+------+---------+-------+---------------------------------+---------+ @@ -110,7 +82,7 @@ mysql> show full columns from v1; +-------+-----------+-----------+------+------+---------+-------+---------------------------------+---------+ 1 row in set (0.00 sec) -mysql> show full columns from mysql.user; +mysql> SHOW FULL COLUMNS FROM mysql.user; +------------------------+---------------+-------------+------+------+---------+-------+---------------------------------+---------+ | Field | Type | Collation | Null | Key | Default | Extra | Privileges | Comment | +------------------------+---------------+-------------+------+------+---------+-------+---------------------------------+---------+ From 4d4cf30ad681e1ffa38df84d04c5ebbdd16e1b27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Tue, 9 Apr 2024 19:04:35 +0200 Subject: [PATCH 2/3] Update sql-statements/sql-statement-show-columns-from.md Co-authored-by: kennytm --- sql-statements/sql-statement-show-columns-from.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-show-columns-from.md b/sql-statements/sql-statement-show-columns-from.md index 6fd32cb41ba4f..e2dd9c1a03b18 100644 --- a/sql-statements/sql-statement-show-columns-from.md +++ b/sql-statements/sql-statement-show-columns-from.md @@ -18,7 +18,7 @@ The statements `SHOW [FULL] FIELDS FROM `, `DESC `, `DES ```ebnf+diagram ShowColumnsFromStmt ::= - "SHOW" "FULL"? ("COLUMNS" | "FIELDS") ("FROM" | "IN") TableName ("FROM" | "IN" SchemaName)? ShowLikeOrWhereOpt? + "SHOW" "FULL"? ("COLUMNS" | "FIELDS") ("FROM" | "IN") TableName ( ("FROM" | "IN") SchemaName)? ShowLikeOrWhere? TableName ::= (Identifier ".")? Identifier From 83dd48376880861c376872bb3bc3645c13083201 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Tue, 9 Apr 2024 19:04:47 +0200 Subject: [PATCH 3/3] Update sql-statements/sql-statement-show-columns-from.md Co-authored-by: kennytm --- sql-statements/sql-statement-show-columns-from.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-show-columns-from.md b/sql-statements/sql-statement-show-columns-from.md index e2dd9c1a03b18..41de5fb623561 100644 --- a/sql-statements/sql-statement-show-columns-from.md +++ b/sql-statements/sql-statement-show-columns-from.md @@ -23,7 +23,7 @@ ShowColumnsFromStmt ::= TableName ::= (Identifier ".")? Identifier -ShowLikeOrWhereOpt ::= +ShowLikeOrWhere ::= "LIKE" SimpleExpr | "WHERE" Expression ```