为什么在SELECT * FROM table_name\G中的\G? [英] Why the \G in SELECT * FROM table_name\G?

查看:2425
本文介绍了为什么在SELECT * FROM table_name\G中的\G?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 \G 而不是; 终止MySQL查询将导致MySQL返回垂直



示例:

  mysql> SELECT * FROM help_keyword LIMIT 3 \G 
*************************** 1. row ******* ********************
help_keyword_id:0
name:JOIN
************ *************** 2.行***************************
help_keyword_id :1
name:REPEAT
*************************** 3. row ******* ********************
help_keyword_id:2
名称:SERIALIZABLE
集合中的3行(0.00秒)

我的问题纯粹的好奇心:有什么理由背后选择字符组合 \



$

ol>
  • 这可能意味着go。

  • PostgreSQL还使用\g作为语句终止符。 PostgreSQL比MySQL早,所以它可能影响了他们。

  • 但是正如我在上面Andriyev的评论中指出的,使\G大写,使显示垂直布局。小写\g没有这个效果,或者如果它,那么文档没有提到它。 (我没有MySQL安装方便试用。)


    Terminating a MySQL query with \G instead of ; will cause MySQL to return the result set in vertical format, which is sometimes easier to read if the number of returned columns is large.

    Example:

    mysql> SELECT * FROM help_keyword LIMIT 3\G
    *************************** 1. row ***************************
    help_keyword_id: 0
               name: JOIN
    *************************** 2. row ***************************
    help_keyword_id: 1
               name: REPEAT
    *************************** 3. row ***************************
    help_keyword_id: 2
               name: SERIALIZABLE
    3 rows in set (0.00 sec)
    

    My question asked out of pure curiosity: Is there any rationale behind choosing the character combination \G?

    解决方案

    My thoughts:

    1. It probably means "go".
    2. Postgresql also uses \g as a statement terminator. Postgresql is older than MySQL so it might have influenced them.

    But as I pointed out in my comment to Andriyev's post above, it's actually making the \G uppercase that causes the display to be laid out vertically. Lowercase \g doesn't have that effect, or if it does then the documentation doesn't mention it. (I don't have a MySQL install handy to try it out.)

    这篇关于为什么在SELECT * FROM table_name\G中的\G?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    相关文章
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆