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 columns from #17087

Merged
merged 3 commits into from
Apr 19, 2024
Merged
Changes from 1 commit
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
62 changes: 17 additions & 45 deletions sql-statements/sql-statement-show-columns-from.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,101 +16,73 @@ The statements `SHOW [FULL] FIELDS FROM <table_name>`, `DESC <table_name>`, `DES

## Synopsis

**ShowStmt:**
```ebnf+diagram
ShowColumnsFromStmt ::=
"SHOW" "FULL"? ("COLUMNS" | "FIELDS") ("FROM" | "IN") TableName ("FROM" | "IN" SchemaName)? ShowLikeOrWhereOpt?
dveeden marked this conversation as resolved.
Show resolved Hide resolved

![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 ::=
dveeden marked this conversation as resolved.
Show resolved Hide resolved
"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 |
+-------+-----------+------+------+---------+-------+
| 1 | bigint(1) | YES | | NULL | |
+-------+-----------+------+------+---------+-------+
1 row in set (0.00 sec)

mysql> desc v1;
mysql> DESC v1;
+-------+-----------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------+------+------+---------+-------+
| 1 | bigint(1) | YES | | NULL | |
+-------+-----------+------+------+---------+-------+
1 row in set (0.00 sec)

mysql> describe v1;
mysql> DESCRIBE v1;
+-------+-----------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------+------+------+---------+-------+
| 1 | bigint(1) | YES | | NULL | |
+-------+-----------+------+------+---------+-------+
1 row in set (0.00 sec)

mysql> explain v1;
mysql> EXPLAIN v1;
+-------+-----------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------+------+------+---------+-------+
| 1 | bigint(1) | YES | | NULL | |
+-------+-----------+------+------+---------+-------+
1 row in set (0.00 sec)

mysql> show fields from v1;
mysql> SHOW FIELDS FROM v1;
+-------+-----------+------+------+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+-----------+------+------+---------+-------+
| 1 | bigint(1) | YES | | NULL | |
+-------+-----------+------+------+---------+-------+
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 |
+-------+-----------+-----------+------+------+---------+-------+---------------------------------+---------+
| 1 | bigint(1) | NULL | YES | | NULL | | select,insert,update,references | |
+-------+-----------+-----------+------+------+---------+-------+---------------------------------+---------+
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 |
+------------------------+---------------+-------------+------+------+---------+-------+---------------------------------+---------+
Expand Down
Loading