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 (
) 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,那么除了字符集和分隔符之外,所有 mysql 命令都将被禁用,前提是输入通过管道输送到 mysql 或使用 source 命令加载。
每个命令都有长形式和短形式。
Learn MySQL in-depth with real-world projects through our MySQL certification course. Enroll and become a certified expert to boost your career.
长形式命令
长形式不区分大小写,而短形式区分大小写。长形式后可以跟一个可选的分号终止符,但短形式后不应跟任何内容。
短形式命令
不支持在多行/* ... */注释中使用短形式命令。短形式命令在单行/*! ... */版本注释中适用,优化器提示注释/*+ ... */也适用。它们存储在对象定义中。
广告