8、使用命令文档
许多用户都知道mysql客户端的内置文档,输入help命令时,它会显示一长串的命令列表。
mysql>help
... List of all MySQL commands: Note that all text commands must be first on line and end with ';' ? (?) Synonym for `help'. clear (c) Clear the current input statement. connect (r) Reconnect to the server. Optional arguments are db and host. delimiter (d) Set statement delimiter. ...
... List of all MySQL commands: Note that all text commands must be first on line and end with ';' ? (?) Synonym for `help'. clear (c) Clear the current input statement. connect (r) Reconnect to the server. Optional arguments are db and host. delimiter (d) Set statement delimiter. ...
如果你不知道DESCRIBE命令如何使用,只需要输入
mysql>help describe;
Name: 'DESCRIBE' Description: Syntax: {DESCRIBE | DESC} tbl_name [col_name | wild] DESCRIBE provides information about the columns in a table. It is a shortcut for SHOW COLUMNS FROM. These statements also display information for views. (See [HELP SHOW COLUMNS].) ...
Name: 'DESCRIBE' Description: Syntax: {DESCRIBE | DESC} tbl_name [col_name | wild] DESCRIBE provides information about the columns in a table. It is a shortcut for SHOW COLUMNS FROM. These statements also display information for views. (See [HELP SHOW COLUMNS].) ...
9、使用Pager
有时你可能想查看表的某一行数据,但在屏幕上往往会显示满屏的数据,除了使用LIMIT子句外,开启客户端pager,设置你的系统分页实用程序:
mysql>pager more PAGER set to 'more'
如果要禁用pager,执行nopager命令即可。
10、将输出内容转储到文件
你可能偶尔需要将SQL执行结果输出到一个文本文件,可以使用SELECT INTO OUTFILE command命令达到目的,或直接在mysql客户端中启用tee命令,并制定输出文件实现同样的功能,如:
mysql>tee sales_report.txt
小结
不管你是挑选其中一部分还是尝试这10个技巧,它们都会为你节省大量的时间和精力,并会减轻你的痛苦,如果你知道其它MySQL命令行技巧,不妨在评论中一起分享一下吧!
原文出处:http://www.developer.com/db/10-command-line-timesavers-for-mysql-tasks.html