Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
164 views
in Technique[技术] by (71.8m points)

mysql - Why the G in SELECT * FROM table_nameG?

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 3G
*************************** 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?

question from:https://stackoverflow.com/questions/2277014/why-the-g-in-select-from-table-name-g

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...