MySQL 如何在不加终止分号的情况下运行MySQL语句?

MySQL 如何在不加终止分号的情况下运行MySQL语句?

通过在MySQL语句的末尾使用 \G 或 \g 选项,我们可以在没有分号的情况下运行它。考虑下面的例子:

mysql> Select * from Stock_item\G
*************************** 1. row ***************************
item_name: Calculator
    Value: 15
 Quantity: 89
*************************** 2. row ***************************
item_name: Notebooks
    Value: 63
 Quantity: 40
*************************** 3. row ***************************
item_name: Pencil
    Value: 15
 Quantity: 40
*************************** 4. row ***************************
item_name: Pens
  Value : 65
Quantity: 32
*************************** 5. row ***************************
item_name: Shirts
    Value: 13
 Quantity: 29
*************************** 6. row ***************************
item_name: Shoes
    Value: 15
 Quantity: 29
*************************** 7. row ***************************
item_name: Trousers
    Value: 15
 Quantity: 29
7 rows in set (0.00 sec)

上面的查询使用\ G(省略分号),以垂直格式返回结果集。

mysql> Select * from Stock_item\g
+------------+-------+----------+
| item_name  | Value | Quantity |
+------------+-------+----------+
| Calculator |    15 |       89 |
| Notebooks  |    63 |       40 |
| Pencil     |    15 |       40 |
| Pens       |    65 |       32 |
| Shirts     |    13 |       29 |
| Shoes      |    15 |       29 |
| Trousers   |    15 |       29 |
+------------+-------+----------+
7 rows in set (0.00 sec)

上面的查询使用\ g(省略分号),以表格格式返回结果集。

阅读更多:MySQL 教程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程