MySQL客户端命令

让我们了解一些MySQL客户端命令-

MySQL将用户发出的每个SQL语句发送到服务器,以便可以执行它。还有一组mysql自己解释的命令。

获取命令列表

通过在提示符下键入以下提到的命令,可以找到这些命令的列表-

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.
edit      (\e) Edit command with $EDITOR.
ego       (\G) Send command to mysql server, display result vertically.
exit      (\q) Exit mysql. Same as quit.
go        (\g) Send command to mysql server.
help      (\h) Display this help.
nopager   (\n) Disable pager, print to stdout.
notee     (\t) Don't write into outfile.
pager     (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print     (\p) Print current command.
prompt    (\R) Change your mysql prompt.
quit      (\q) Quit mysql.
rehash    (\#) Rebuild completion hash.
source    (\.) Execute an SQL script file. Takes a file name as an argument.
status    (\s) Get status information from the server.
system    (\!) Execute a system shell command.
tee       (\T) Set outfile [to_outfile]. Append everything into given    outfile.
use       (\u) Use another database. Takes database name as argument.
charset   (\C) Switch to another charset. Might be needed for processing  binlog with multi-byte charsets.
warnings  (\W) Show warnings after every statement.

如果使用'--binary-mode'选项调用mysql,则在非交互模式下,除charset和delimiter外,所有mysql命令都将被禁用,因为输入是通过管道传递到mysql或使用source命令加载的。

每个命令都有长号和短号两种形式。

长格式命令

长格式不区分大小写,而短格式则区分大小写。长格式可以后面跟一个可选的分号终止符,但短格式后面不能跟任何东西。

短格式命令

不支持在多行/ * ... * /注释中使用短格式命令。简写命令可在单行/ *中使用!... * /版本注释,/ * + ... * /优化程序提示注释也是如此。它们存储在对象定义中。