[DOC] Mysql basic queries

Status information

SHOW AUTHORS
SHOW {BINARY | MASTER} LOGS
SHOW BINLOG EVENTS [IN 'log_name'] [FROM pos] [LIMIT [offset,] ROW_COUNT]
SHOW CHARACTER SET [like_or_where]
SHOW COLLATION [like_or_where]
SHOW [FULL] COLUMNS FROM tbl_name [FROM db_name] [like_or_where]
SHOW CONTRIBUTORS
SHOW CREATE DATABASE db_name
SHOW CREATE EVENT event_name
SHOW CREATE FUNCTION func_name
SHOW CREATE PROCEDURE proc_name
SHOW CREATE TABLE tbl_name
SHOW CREATE TRIGGER trigger_name
SHOW CREATE VIEW view_name
SHOW DATABASES [like_or_where]
SHOW ENGINE engine_name {STATUS | MUTEX}
SHOW [STORAGE] ENGINES
SHOW ERRORS [LIMIT [offset,] ROW_COUNT]
SHOW EVENTS
SHOW FUNCTION CODE func_name
SHOW FUNCTION STATUS [like_or_where]
SHOW GRANTS FOR USER
SHOW INDEX FROM tbl_name [FROM db_name]
SHOW MASTER STATUS
SHOW OPEN TABLES [FROM db_name] [like_or_where]
SHOW PLUGINS
SHOW PROCEDURE CODE proc_name
SHOW PROCEDURE STATUS [like_or_where]
SHOW PRIVILEGES
SHOW [FULL] PROCESSLIST
SHOW PROFILE [types] [FOR QUERY n] [OFFSET n] [LIMIT n]
SHOW PROFILES
SHOW SLAVE HOSTS
SHOW SLAVE STATUS
SHOW [GLOBAL | SESSION] STATUS [like_or_where]
SHOW TABLE STATUS [FROM db_name] [like_or_where]
SHOW [FULL] TABLES [FROM db_name] [like_or_where]
SHOW TRIGGERS [FROM db_name] [like_or_where]
SHOW [GLOBAL | SESSION] VARIABLES [like_or_where]
SHOW WARNINGS [LIMIT [offset,] ROW_COUNT]

Objects

All “SHOW <OBJECT_TYPE>” commands accept “like” to limit the query results:

 LIKE '%OBJECT_NAME%' ;
SHOW FUNCTION STATUS ;
SHOW PROCEDURE STATUS ;
SHOW TRIGGERS ;
SELECT table_schema, TABLE_NAME, table_type, table_rows, engine, version FROM information_schema.tables ;
SHOW TABLES ;
SHOW FULL TABLES ;
SHOW TABLE STATUS ;
SHOW INDEX FROM tbl_name [FROM db_name]
SELECT DISTINCT
    TABLE_NAME,
    INDEX_NAME
FROM INFORMATION_SCHEMA.STATISTICS
WHERE TABLE_SCHEMA = 'your_schema';

Table

SHOW CREATE TABLE TABLENAME ;

Function

SHOW CREATE FUNCTION FUNCTIONNAME ;

o

SELECT body_utf8 FROM mysql.proc WHERE db='<DATABASENAME>' AND name='FUNCTIONNAME' AND TYPE='FUNCTION' ;

Master/Slave

SHOW master STATUS ;
SHOW slave STATUS \G
PURGE BINARY LOGS TO 'mysql-bin.000060';
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;

In the case that the slave keep old settings (like renaming the relay-log)

reset slave ;
 
 
 
 
 
  • mysql/mysql_basic_queries.txt
  • Last modified: 2018/05/17 09:04
  • by dodger