MYSQL入門學習之十七:MYSQL命令行內可使用的命令詳細說明 相關鏈接: MYSQL入門學習之一:基本操作 http://www.BkJia.com/database/201212/173868.html MYSQL入門學習之二:使用正則表達式搜索 http://www.BkJia.com/database/201212/173869.html MYSQL入門學習之三:全文本搜索 http://www.BkJia.com/database/201212/173873.html MYSQL入門學習之四:MYSQL的數據類型 http://www.BkJia.com/database/201212/175536.html MYSQL入門學習之五:MYSQL的字符集 http://www.BkJia.com/database/201212/175541.html MYSQL入門學習之六:MYSQL的運算符 http://www.BkJia.com/database/201212/175862.html MYSQL入門學習之七:MYSQL常用函數 http://www.BkJia.com/database/201212/175864.html MYSQL入門學習之八:數據庫及表的基本操作 http://www.BkJia.com/database/201212/175867.html MYSQL入門學習之九:索引的簡單操作 http://www.BkJia.com/database/201212/176772.html MYSQL入門學習之十:視圖的基本操作 http://www.BkJia.com/database/201212/176775.html MYSQL入門學習之十一:觸發器的基本操作 http://www.BkJia.com/database/201212/176781.html MYSQL入門學習之十二:存儲過程的基本操作 http://www.BkJia.com/database/201212/177380.html MYSQL入門學習之十三:自定義函數的基本操作 http://www.BkJia.com/database/201212/177382.html MYSQL入門學習之十四:游標的基本操作 http://www.BkJia.com/database/201212/177384.html MYSQL入門學習之十五:事務處理的基本操作 http://www.BkJia.com/database/201212/177385.html MYSQL入門學習之十六:MYSQL命令參數詳解 http://www.BkJia.com/database/201212/178079.html 在MYSQL命令行中,有一些非常實用的小命令可以使用。 進行MYSQL命令行後,輸入\h,可查看MYSQL命令行支持的小命令及對應的功能說明: [sql] www.2cto.com mysql> \h For information about MySQL products and services, visit: http://www.mysql.com/ For developer information, including the MySQL Reference Manual, visit: http://dev.mysql.com/ To buy MySQL Network Support, training, or other products, visit: https://shop.mysql.com/ List of all MySQL commands: Note that all text commands must be first on line and end with ';' ? (\?) Synonym for `help'. clear (\c) Clear command. connect (\r) Reconnect to the server. Optional arguments are db and host. delimiter (\d) Set statement delimiter. NOTE: Takes the rest of the line as new delimiter. 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. notee (\t) Don't write into outfile. 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. 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. nowarning (\w) Don't show warnings after every statement. For server side help, type 'help contents' 這段輸出主要包含兩部分信息: 第一部分為MYSQL客戶端相關的小命令,其對應的中文翻譯如下: ? (\?) 顯示幫助信息。與\h的功能相同 clear (\c) 不執行當前正在輸入的命令。若\c前已包含命令分隔符,則命令分隔符之前的部分仍然執行。 connect (\r) 重新連接到服務器。該命令有兩個參數:數據庫名和服務器主機名,其中主機名可省略。 delimiter (\d) 修改命令分隔符 ego (\G) 將命令的結果以垂直的形式顯示 exit (\q) 退出 go (\g) 向服務器發送命令。在語句的最後使用,可替代命令分隔符。 help (\h) 顯示幫助信息。與\?的功能相同 notee (\t) 不要寫入OUTFILE print (\p) 顯示當前執行的命令 prompt (\R) 修改MYSQL的提示符 quit (\q) 退出 rehash (\#) source (\.) 執行參數文件中的SQL腳本 status (\s) 獲取服務器端狀態 tee (\T) 指定一個輸出文件,將命令行中的所有操作及結果記入此文件 use (\u) 轉換當前使用的數據庫 charset (\C) 轉換當前connection及client的字符集 warnings (\W) 顯示警告信息 nowarning (\w) 不顯示警告信息 示例: [sql] mysql> select count(*) from newname\c mysql> select count(*) from newname;\c +----------+ | count(*) | +----------+ | 159 | +----------+ mysql>\R this is mysql5 > PROMPT set to 'this is mysql5 >' this is mysql5 >\. h:\select.sql +----------+ | count(*) | +----------+ | 159 | +----------+ this is mysql5 >\s -------------- mysql Ver 14.14 Distrib 5.1.28-rc, for Win32 (ia32) Connection id: 25 Current database: test Current user: root@localhost SSL: Not in use Using delimiter: ; Server version: 5.1.28-rc-community MySQL Community Server (GPL) Protocol version: 10 Connection: localhost via TCP/IP Server characterset: latin1 Db characterset: latin1 Client characterset: gbk Conn. characterset: gbk TCP port: 3306 Uptime: 1 hour 29 min 31 sec Threads: 1 Questions: 55 Slow queries: 0 Opens: 24 Flush tables: 1 Open tables: 5 Queries per second avg: 0.10 -------------- this is mysql5 >\T h:\a.txt Logging to file 'h:\a.txt' this is mysql5 >\q Bye 第二部分為查看MYSQL服務端相關信息的命令,使用help contents可以查看其用法: [sql] mysql> help contents You asked for help about help category: "Contents" For more information, type 'help <item>', where <item> is one of the following categories: Account Management Administration Data Definition Data Manipulation Data Types Functions Functions and Modifiers for Use with GROUP BY Geographic Features Language Structure Plugins Storage Engines Stored Routines Table Maintenance Transactions Triggers 對於某些help命令的結果,仍然可以使用help進行進一步的查看。如help Data Types的結果如下: [sql] mysql> help Data Types You asked for help about help category: "Data Types" For more information, type 'help <item>', where <item> is one of the following topics: AUTO_INCREMENT BIGINT BINARY BIT BLOB BLOB DATA TYPE BOOLEAN CHAR CHAR BYTE DATE DATETIME DEC DECIMAL DOUBLE DOUBLE PRECISION ENUM FLOAT INT INTEGER LONGBLOB LONGTEXT MEDIUMBLOB MEDIUMINT MEDIUMTEXT SET DATA TYPE SMALLINT TEXT TIME TIMESTAMP TINYBLOB TINYINT TINYTEXT VARBINARY VARCHAR YEAR DATA TYPE 仍然可以使用help INT,查看INT數據類型的詳細信息: [sql] mysql> help INT Name: 'INT' Description: INT[(M)] [UNSIGNED] [ZEROFILL] A normal-size integer. The signed range is -2147483648 to 2147483647. The unsigned range is 0 to 4294967295. URL: http://dev.mysql.com/doc/refman/5.1/en/numeric-type-overview.html 由結果可以查看INT類型的用法,以及INT數據類型能表示的數據范圍。