mirror of
https://github.com/jbranchaud/til
synced 2026-01-15 04:58:02 +00:00
Add Display Output In A Vertical Format as a mysql til
This commit is contained in:
@@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
|
|||||||
For a steady stream of TILs from a variety of rocketeers, checkout
|
For a steady stream of TILs from a variety of rocketeers, checkout
|
||||||
[til.hashrocket.com](https://til.hashrocket.com/).
|
[til.hashrocket.com](https://til.hashrocket.com/).
|
||||||
|
|
||||||
_536 TILs and counting..._
|
_537 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -231,6 +231,7 @@ _536 TILs and counting..._
|
|||||||
|
|
||||||
### MySQL
|
### MySQL
|
||||||
|
|
||||||
|
- [Display Output In A Vertical Format](mysql/display-output-in-a-vertical-format.md)
|
||||||
- [List Databases And Tables](mysql/list-databases-and-tables.md)
|
- [List Databases And Tables](mysql/list-databases-and-tables.md)
|
||||||
- [Show Indexes For A Table](mysql/show-indexes-for-a-table.md)
|
- [Show Indexes For A Table](mysql/show-indexes-for-a-table.md)
|
||||||
|
|
||||||
|
|||||||
50
mysql/display-output-in-a-vertical-format.md
Normal file
50
mysql/display-output-in-a-vertical-format.md
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
# Display Output In A Vertical Format
|
||||||
|
|
||||||
|
Output for tables with lots of columns can be hard to read and sometimes
|
||||||
|
overflow the terminal window. Consider the output from [Show Indexes For A
|
||||||
|
Table](show-indexes-for-a-table.md):
|
||||||
|
|
||||||
|
```sql
|
||||||
|
> show indexes in users;
|
||||||
|
+-------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
|
||||||
|
| Table | Non_unique | Key_name | Seq_in_index | Column_name | Collation | Cardinality | Sub_part | Packed | Null | Index_type | Comment | Index_comment |
|
||||||
|
+-------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
|
||||||
|
| users | 0 | PRIMARY | 1 | id | A | 0 | NULL | NULL | | BTREE | | |
|
||||||
|
| users | 0 | unique_email | 1 | email | A | 0 | NULL | NULL | | BTREE | | |
|
||||||
|
+-------+------------+--------------+--------------+-------------+-----------+-------------+----------+--------+------+------------+---------+---------------+
|
||||||
|
```
|
||||||
|
|
||||||
|
We can vertically orient the output of a statement by terminating it with
|
||||||
|
`\G` instead of `;` (or `\g`).
|
||||||
|
|
||||||
|
```sql
|
||||||
|
> show indexes in users\G
|
||||||
|
*************************** 1. row ***************************
|
||||||
|
Table: users
|
||||||
|
Non_unique: 0
|
||||||
|
Key_name: PRIMARY
|
||||||
|
Seq_in_index: 1
|
||||||
|
Column_name: id
|
||||||
|
Collation: A
|
||||||
|
Cardinality: 0
|
||||||
|
Sub_part: NULL
|
||||||
|
Packed: NULL
|
||||||
|
Null:
|
||||||
|
Index_type: BTREE
|
||||||
|
Comment:
|
||||||
|
Index_comment:
|
||||||
|
*************************** 2. row ***************************
|
||||||
|
Table: users
|
||||||
|
Non_unique: 0
|
||||||
|
Key_name: unique_email
|
||||||
|
Seq_in_index: 1
|
||||||
|
Column_name: email
|
||||||
|
Collation: A
|
||||||
|
Cardinality: 0
|
||||||
|
Sub_part: NULL
|
||||||
|
Packed: NULL
|
||||||
|
Null:
|
||||||
|
Index_type: BTREE
|
||||||
|
Comment:
|
||||||
|
Index_comment:
|
||||||
|
```
|
||||||
Reference in New Issue
Block a user