mysql有很完善的帮助文档,在mysql命令行下可以通过? 或者help 加上命令可以查看改命令的帮助信息,
我们查下几个常用的help命令
第一层帮助信息:
? contents;
mysql> ? contents;You asked for help about help category: "Contents"For more information, type 'help- ', where
- is one of the followingcategories: Account Management Administration Compound Statements Data Definition Data Manipulation Data Types Functions Functions and Modifiers for Use with GROUP BY Geographic Features Help Metadata Language Structure Plugins Table Maintenance Transactions User-Defined Functions Utility
再查看具体每一层的帮助信息
mysql> ? Account Management;
You asked for help about help category: "Account Management"For more information, type 'help- ', where
- is one of the followingtopics: CREATE USER DROP USER GRANT RENAME USER REVOKE SET PASSWORDmysql> ? AdministrationYou asked for help about help category: "Administration"For more information, type 'help
- ', where
- is one of the followingtopics: BINLOG CACHE INDEX CHANGE MASTER TO DEALLOCATE PREPARE EXECUTE STATEMENT FLUSH FLUSH QUERY CACHE HELP COMMAND KILL LOAD INDEX PREPARE PURGE BINARY LOGS RESET RESET MASTER RESET SLAVE SET SET GLOBAL SQL_SLAVE_SKIP_COUNTER SET SQL_LOG_BIN SHOW SHOW AUTHORS SHOW BINARY LOGS SHOW BINLOG EVENTS SHOW CHARACTER SET SHOW COLLATION SHOW COLUMNS SHOW CONTRIBUTORS SHOW CREATE DATABASE SHOW CREATE EVENT SHOW CREATE FUNCTION SHOW CREATE PROCEDURE SHOW CREATE TABLE SHOW CREATE TRIGGER SHOW CREATE VIEW SHOW DATABASES SHOW ENGINE SHOW ENGINES SHOW ERRORS SHOW EVENTS SHOW FUNCTION CODE SHOW FUNCTION STATUS SHOW GRANTS SHOW INDEX SHOW MASTER STATUS SHOW OPEN TABLES SHOW PLUGINS SHOW PRIVILEGES SHOW PROCEDURE CODE SHOW PROCEDURE STATUS SHOW PROCESSLIST SHOW PROFILE SHOW PROFILES SHOW RELAYLOG EVENTS SHOW SLAVE HOSTS SHOW SLAVE STATUS SHOW STATUS SHOW TABLE STATUS SHOW TABLES SHOW TRIGGERS SHOW VARIABLES SHOW WARNINGS START SLAVE STOP SLAVEmysql> ? Compound Statements;You asked for help about help category: "Compound Statements"For more information, type 'help
- ', where
- is one of the followingtopics: BEGIN END CASE STATEMENT CLOSE DECLARE CONDITION DECLARE CURSOR DECLARE HANDLER DECLARE VARIABLE FETCH IF STATEMENT ITERATE LEAVE LOOP OPEN REPEAT LOOP RESIGNAL RETURN SELECT INTO SET VARIABLE SIGNAL WHILEmysql> ? Data Definition;You asked for help about help category: "Data Definition"For more information, type 'help
- ', where
- is one of the followingtopics: ALTER DATABASE ALTER EVENT ALTER FUNCTION ALTER PROCEDURE ALTER SERVER ALTER TABLE ALTER VIEW CONSTRAINT CREATE DATABASE CREATE EVENT CREATE FUNCTION CREATE INDEX CREATE PROCEDURE CREATE SERVER CREATE TABLE CREATE TRIGGER CREATE VIEW DROP DATABASE DROP EVENT DROP FUNCTION DROP INDEX DROP PROCEDURE DROP SERVER DROP TABLE DROP TRIGGER DROP VIEW MERGE RENAME TABLE TRUNCATE TABLE
这里可以根据不同的分类显示每个分类下支持的mysql指令
mysql> ? START SLAVE;
Name: 'START SLAVE'Description:Syntax:START SLAVE [thread_type [, thread_type] ... ]START SLAVE [SQL_THREAD] UNTIL MASTER_LOG_FILE = 'log_name', MASTER_LOG_POS = log_posSTART SLAVE [SQL_THREAD] UNTIL RELAY_LOG_FILE = 'log_name', RELAY_LOG_POS = log_posthread_type: IO_THREAD | SQL_THREADSTART SLAVE with no thread_type options starts both of the slavethreads. The I/O thread reads events from the master server and storesthem in the relay log. The SQL thread reads events from the relay logand executes them. START SLAVE requires the SUPER privilege.If START SLAVE succeeds in starting the slave threads, it returnswithout any error. However, even in that case, it might be that theslave threads start and then later stop (for example, because they donot manage to connect to the master or read its binary log, or someother problem). START SLAVE does not warn you about this. You mustcheck the slave's error log for error messages generated by the slavethreads, or check that they are running satisfactorily with SHOW SLAVESTATUS.URL: http://dev.mysql.com/doc/refman/5.5/en/start-slave.htmlmysql> ? MERGEName: 'MERGE'Description:The MERGE storage engine, also known as the MRG_MyISAM engine, is acollection of identical MyISAM tables that can be used as one."Identical" means that all tables have identical column and indexinformation. You cannot merge MyISAM tables in which the columns arelisted in a different order, do not have exactly the same columns, orhave the indexes in different order. However, any or all of the MyISAMtables can be compressed with myisampack. Seehttp://dev.mysql.com/doc/refman/5.5/en/myisampack.html. Differences intable options such as AVG_ROW_LENGTH, MAX_ROWS, or PACK_KEYS do notmatter.URL: http://dev.mysql.com/doc/refman/5.5/en/merge-storage-engine.htmlExamples:mysql> CREATE TABLE t1 ( -> a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, -> message CHAR(20)) ENGINE=MyISAMmysql> CREATE TABLE t2 ( -> a INT NOT NULL AUTO_INCREMENT PRIMARY KEY, -> message CHAR(20)) ENGINE=MyISAMmysql> INSERT INTO t1 (message) VALUES ('Testing'),('table'),('t1')mysql> INSERT INTO t2 (message) VALUES ('Testing'),('table'),('t2')mysql> CREATE TABLE total ( -> a INT NOT NULL AUTO_INCREMENT, -> message CHAR(20), INDEX(a)) -> ENGINE=MERGE UNION=(t1,t2) INSERT_METHOD=LASTmysql> ? create table;Name: 'CREATE TABLE'Description:Syntax:CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name (create_definition,...) [table_options] [partition_options]Or:CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)] [table_options] [partition_options] select_statementOr:CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name { LIKE old_tbl_name | (LIKE old_tbl_name) }create_definition: col_name column_definition | [CONSTRAINT [symbol]] PRIMARY KEY [index_type] (index_col_name,...) [index_option] ... | {INDEX|KEY} [index_name] [index_type] (index_col_name,...) [index_option] ... | [CONSTRAINT [symbol]] UNIQUE [INDEX|KEY] [index_name] [index_type] (index_col_name,...) [index_option] ... | {FULLTEXT|SPATIAL} [INDEX|KEY] [index_name] (index_col_name,...) [index_option] ... | [CONSTRAINT [symbol]] FOREIGN KEY [index_name] (index_col_name,...) reference_definition | CHECK (expr)column_definition: data_type [NOT NULL | NULL] [DEFAULT default_value] [AUTO_INCREMENT] [UNIQUE [KEY] | [PRIMARY] KEY] [COMMENT 'string'] [COLUMN_FORMAT {FIXED|DYNAMIC|DEFAULT}] [reference_definition]data_type: BIT[(length)] | TINYINT[(length)] [UNSIGNED] [ZEROFILL] | SMALLINT[(length)] [UNSIGNED] [ZEROFILL] | MEDIUMINT[(length)] [UNSIGNED] [ZEROFILL] | INT[(length)] [UNSIGNED] [ZEROFILL] | INTEGER[(length)] [UNSIGNED] [ZEROFILL] | BIGINT[(length)] [UNSIGNED] [ZEROFILL] | REAL[(length,decimals)] [UNSIGNED] [ZEROFILL] | DOUBLE[(length,decimals)] [UNSIGNED] [ZEROFILL] | FLOAT[(length,decimals)] [UNSIGNED] [ZEROFILL] | DECIMAL[(length[,decimals])] [UNSIGNED] [ZEROFILL] | NUMERIC[(length[,decimals])] [UNSIGNED] [ZEROFILL] | DATE | TIME | TIMESTAMP | DATETIME | YEAR | CHAR[(length)] [CHARACTER SET charset_name] [COLLATE collation_name] | VARCHAR(length) [CHARACTER SET charset_name] [COLLATE collation_name] | BINARY[(length)] | VARBINARY(length) | TINYBLOB | BLOB | MEDIUMBLOB | LONGBLOB | TINYTEXT [BINARY] [CHARACTER SET charset_name] [COLLATE collation_name] | TEXT [BINARY] [CHARACTER SET charset_name] [COLLATE collation_name] | MEDIUMTEXT [BINARY] [CHARACTER SET charset_name] [COLLATE collation_name] | LONGTEXT [BINARY] [CHARACTER SET charset_name] [COLLATE collation_name] | ENUM(value1,value2,value3,...) [CHARACTER SET charset_name] [COLLATE collation_name] | SET(value1,value2,value3,...) [CHARACTER SET charset_name] [COLLATE collation_name] | spatial_typeindex_col_name: col_name [(length)] [ASC | DESC]index_type: USING {BTREE | HASH}index_option: KEY_BLOCK_SIZE [=] value | index_type | WITH PARSER parser_name | COMMENT 'string'reference_definition: REFERENCES tbl_name (index_col_name,...) [MATCH FULL | MATCH PARTIAL | MATCH SIMPLE] [ON DELETE reference_option] [ON UPDATE reference_option]reference_option: RESTRICT | CASCADE | SET NULL | NO ACTIONtable_options: table_option [[,] table_option] ...table_option: ENGINE [=] engine_name | AUTO_INCREMENT [=] value | AVG_ROW_LENGTH [=] value | [DEFAULT] CHARACTER SET [=] charset_name | CHECKSUM [=] {0 | 1} | [DEFAULT] COLLATE [=] collation_name | COMMENT [=] 'string' | CONNECTION [=] 'connect_string' | DATA DIRECTORY [=] 'absolute path to directory' | DELAY_KEY_WRITE [=] {0 | 1} | INDEX DIRECTORY [=] 'absolute path to directory' | INSERT_METHOD [=] { NO | FIRST | LAST } | KEY_BLOCK_SIZE [=] value | MAX_ROWS [=] value | MIN_ROWS [=] value | PACK_KEYS [=] {0 | 1 | DEFAULT} | PASSWORD [=] 'string' | ROW_FORMAT [=] {DEFAULT|DYNAMIC|FIXED|COMPRESSED|REDUNDANT|COMPACT} | UNION [=] (tbl_name[,tbl_name]...)partition_options: PARTITION BY { [LINEAR] HASH(expr) | [LINEAR] KEY(column_list) | RANGE{(expr) | COLUMNS(column_list)} | LIST{(expr) | COLUMNS(column_list)} } [PARTITIONS num] [SUBPARTITION BY { [LINEAR] HASH(expr) | [LINEAR] KEY(column_list) } [SUBPARTITIONS num] ] [(partition_definition [, partition_definition] ...)]partition_definition: PARTITION partition_name [VALUES {LESS THAN {(expr | value_list) | MAXVALUE} | IN (value_list)}] [[STORAGE] ENGINE [=] engine_name] [COMMENT [=] 'comment_text' ] [DATA DIRECTORY [=] 'data_dir'] [INDEX DIRECTORY [=] 'index_dir'] [MAX_ROWS [=] max_number_of_rows] [MIN_ROWS [=] min_number_of_rows] [(subpartition_definition [, subpartition_definition] ...)]subpartition_definition: SUBPARTITION logical_name [[STORAGE] ENGINE [=] engine_name] [COMMENT [=] 'comment_text' ] [DATA DIRECTORY [=] 'data_dir'] [INDEX DIRECTORY [=] 'index_dir'] [MAX_ROWS [=] max_number_of_rows] [MIN_ROWS [=] min_number_of_rows]select_statement: [IGNORE | REPLACE] [AS] SELECT ... (Some legal select statement)CREATE TABLE creates a table with the given name. You must have theCREATE privilege for the table.Rules for permissible table names are given inhttp://dev.mysql.com/doc/refman/5.5/en/identifiers.html. By default,the table is created in the default database, using the InnoDB storageengine. An error occurs if the table exists, if there is no defaultdatabase, or if the database does not exist.URL: http://dev.mysql.com/doc/refman/5.5/en/create-table.htmlmysql>至于上面一层的命令,我们还可以查看mysql支持的数据类型,
mysql> ? Data Types;You asked for help about help category: "Data Types"For more information, type 'help- ', where
- is one of the followingtopics: 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 TYPEmysql> ? Utility;You asked for help about help category: "Utility"For more information, type 'help
- ', where
- is one of the followingtopics: DESCRIBE EXPLAIN HELP STATEMENT USE
通过帮助文档还是很方便查到mysql的所有名称,已经每个命令的使用方法和语法。
可以查看mysql内置函数列表,以及每个函数的功能和使用方法:
mysql> ? Functions;You asked for help about help category: "Functions"For more information, type 'helpmysql的插件信息和事务之类的其他信息- ', where
- is one of the followingtopics: PROCEDURE ANALYSEcategories: Bit Functions Comparison operators Control flow functions Date and Time Functions Encryption Functions Information Functions Logical operators Miscellaneous Functions Numeric Functions String Functionsmysql> ? String Functions;You asked for help about help category: "String Functions"For more information, type 'help
- ', where
- is one of the followingtopics: ASCII BIN BINARY OPERATOR BIT_LENGTH CAST CHAR FUNCTION CHARACTER_LENGTH CHAR_LENGTH CONCAT CONCAT_WS CONVERT ELT EXPORT_SET EXTRACTVALUE FIELD FIND_IN_SET FORMAT HEX INSERT FUNCTION INSTR LCASE LEFT LENGTH LIKE LOAD_FILE LOCATE LOWER LPAD LTRIM MAKE_SET MATCH AGAINST MID NOT LIKE NOT REGEXP OCTET_LENGTH ORD POSITION QUOTE REGEXP REPEAT FUNCTION REPLACE FUNCTION REVERSE RIGHT RPAD RTRIM SOUNDEX SOUNDS LIKE SPACE STRCMP SUBSTR SUBSTRING SUBSTRING_INDEX TRIM UCASE UNHEX UPDATEXML UPPERmysql> ? QUOTE;Name: 'QUOTE'Description:Syntax:QUOTE(str)Quotes a string to produce a result that can be used as a properlyescaped data value in an SQL statement. The string is returned enclosedby single quotation marks and with each instance of backslash ("\"),single quote ("'"), ASCII NUL, and Control+Z preceded by a backslash.If the argument is NULL, the return value is the word "NULL" withoutenclosing single quotation marks.URL: http://dev.mysql.com/doc/refman/5.5/en/string-functions.htmlExamples:mysql> SELECT QUOTE('Don\'t!') -> 'Don\'t!'mysql> SELECT QUOTE(NULL) -> NULLmysql>
mysql> ? Plugins;Name: 'SHOW PLUGINS'Description:Syntax:SHOW PLUGINSSHOW PLUGINS displays information about server plugins. Plugininformation is also available in the INFORMATION_SCHEMA.PLUGINS table.See http://dev.mysql.com/doc/refman/5.5/en/plugins-table.html.Example of SHOW PLUGINS output:mysql> SHOW PLUGINS\G*************************** 1. row *************************** Name: binlog Status: ACTIVE Type: STORAGE ENGINELibrary: NULLLicense: GPL*************************** 2. row *************************** Name: CSV Status: ACTIVE Type: STORAGE ENGINELibrary: NULLLicense: GPL*************************** 3. row *************************** Name: MEMORY Status: ACTIVE Type: STORAGE ENGINELibrary: NULLLicense: GPL*************************** 4. row *************************** Name: MyISAM Status: ACTIVE Type: STORAGE ENGINELibrary: NULLLicense: GPL...URL: http://dev.mysql.com/doc/refman/5.5/en/show-plugins.htmlmysql> ? Transations;Nothing foundPlease try to run 'help contents' for a list of all accessible topicsmysql> ? Transactions;You asked for help about help category: "Transactions"For more information, type 'help通过帮助文档可以查询到mysql的所有命令及每个命令的功能,语法。- ', where
- is one of the followingtopics: ISOLATION LOCK SAVEPOINT START TRANSACTIONmysql>