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 命令載入。

每個命令都有長形式和短形式。

長形式命令

長形式不區分大小寫,而短形式區分大小寫。長形式後可以跟一個可選的分號終止符,但短形式後不應跟任何內容。

短形式命令

不支援在多行/* ... */註釋中使用短形式命令。短形式命令在單行/*! ... */版本註釋中適用,最佳化器提示註釋/*+ ... */也適用。它們儲存在物件定義中。

更新於: 2021-03-10

1 千+次瀏覽

啟動 職業

透過完成課程獲取認證

開始
廣告
© . All rights reserved.