MYSQL:使用\G参数改变输出结果集的显示方式
2014-04-22 14:03
549 查看
转自:http://blog.csdn.net/warmspace2008/article/details/8334010
在MYSQL命令行中使用\G参数,将输出按列显示。当需要看表中各字段的值时非常有用。
普通的SQL命令输出如下:
[sql] view
plaincopy
mysql> select * from t_goods;
+------+------------+----------+------------+-----------------------------------
-----------------------------+
| id | goods_name | quantity | add_date | description
|
+------+------------+----------+------------+-----------------------------------
-----------------------------+
| 1 | MYSQL5 | 50 | 2012-12-12 | A book that has been read but is i
n good condition. See the seller’s listing for full details and descr iption of
any imperfections. |
+------+------------+----------+------------+-----------------------------------
-----------------------------+
下面是使用\G选项的输出:
[sql] view
plaincopy
mysql> select * from t_goods \G
*************************** 1. row ***************************
id: 1
goods_name: MYSQL5
quantity: 50
add_date: 2012-12-12
description: A book that has been read but is in good condition. See t
he seller’s listing for full details and description of any imperfections.
注意:\G为大写字母,不可使用小写;使用\G参数后,SQL语句后可以不加分隔符,如果加分隔符,则会报“error:no query specified”的错误。
这样的显示效果与MYSQL命令的-E参数是一样的。使用-E参数后,结果集默认以列的方式显示:
[sql] view
plaincopy
C:\Users\qxl>mysql -uroot -E
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.1.28-rc-community MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use test;
Database changed
mysql> select * from t_goods;
*************************** 1. row ***************************
id: 1
goods_name: MYSQL5
quantity: 50
add_date: 2012-12-12
description: A book that has been read but is in good condition. See t
he seller’s listing for full details and description of any imperfections.
在MYSQL命令行中使用\G参数,将输出按列显示。当需要看表中各字段的值时非常有用。
普通的SQL命令输出如下:
[sql] view
plaincopy
mysql> select * from t_goods;
+------+------------+----------+------------+-----------------------------------
-----------------------------+
| id | goods_name | quantity | add_date | description
|
+------+------------+----------+------------+-----------------------------------
-----------------------------+
| 1 | MYSQL5 | 50 | 2012-12-12 | A book that has been read but is i
n good condition. See the seller’s listing for full details and descr iption of
any imperfections. |
+------+------------+----------+------------+-----------------------------------
-----------------------------+
下面是使用\G选项的输出:
[sql] view
plaincopy
mysql> select * from t_goods \G
*************************** 1. row ***************************
id: 1
goods_name: MYSQL5
quantity: 50
add_date: 2012-12-12
description: A book that has been read but is in good condition. See t
he seller’s listing for full details and description of any imperfections.
注意:\G为大写字母,不可使用小写;使用\G参数后,SQL语句后可以不加分隔符,如果加分隔符,则会报“error:no query specified”的错误。
这样的显示效果与MYSQL命令的-E参数是一样的。使用-E参数后,结果集默认以列的方式显示:
[sql] view
plaincopy
C:\Users\qxl>mysql -uroot -E
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.1.28-rc-community MySQL Community Server (GPL)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use test;
Database changed
mysql> select * from t_goods;
*************************** 1. row ***************************
id: 1
goods_name: MYSQL5
quantity: 50
add_date: 2012-12-12
description: A book that has been read but is in good condition. See t
he seller’s listing for full details and description of any imperfections.
相关文章推荐
- MYSQL:使用/G参数改变输出结果集的显示方式
- shell中使用echo命令改变输出显示样式
- php中使用mysql_fetch_object向页面输出结果,总结!
- 《第九周任务一》定义Complex类中的《《和》》运算符的重载,实现输入和输出,改造原程序中对运算结果显示方式,使程序读起来更自然
- mysql的case then else end语句的使用,来显示多种结果之一
- Log4j输出方法参数不同所显示的结果不同参考
- C++使用system带参数调用exe程序并把结果输出到文件
- 第九周实验报告 任务2 定义Complex类中的<<和>>运算符的重载,实现输入和输出,改造原程序中对运算结果显示方式,使程序读起来更自然。
- 第九周【项目1】在第8周项1的基础上(1)再定义一目运算符 -,-c相当于0-c(2)定义Complex类中的<<和>>运算符的重载,实现输入和输出,改造原程序中对运算结果显示方式,使程序读起来更自然
- mybatis 下 mysql in查询按照参数顺序输出结果
- linux下使用mysql,查询出来的结果中文显示不正常的解决方案
- 需要DLL函数输出的结果信息,尽量使用传入参数做为输出变量~!
- mysql面试题:使用表连接的方式查询出指定的结果
- 例题:把一个超市购物的题做成函数。这个题做成函数没有必要,但可以了解输入参数,输出参数,返回值,函数体,还有结构体,ArryList集合,for循环算结果,以及集合里 .count的使用
- error:使用rebuild编译链接dll文件和exe文件,结果改变产生dll的源文件的内容,输出结果都没有改变
- Mysql编辑工具中使用(Navicat查询结果显示行号)
- 使用表单post方式提交到某个servlet,请求参数不会在地址栏显示,达到隐藏请求参数的目的
- extjs 3.4 使用XTemplate 改变grid行的显示方式
- SharePoint 2013 中使用JSLink 来改变列表中某个字段或view(视图)的显示方式
- 第九周实验报告任务 1 定义Time类中的<<和>>运算符重载,实现时间的输入输出,改造原程序中对运算结果显示方式,使程序读起来更自然。