1.explainhtml
explain是mysql的查詢分析計劃mysql
explain select * from user \G;
explain的partitions操做sql
explain partitions select * from user
explain的extended操做提供explain額外的filtered列數據庫
explain extended select * from test1 t1 inner join test2 t2 using(uid)
2.show warningssession
關於show可參考mysql文檔http://dev.mysql.com/doc/refman/5.7/en/show.htmlui
show warnings用於查看生成的 警告編碼
show warnings \G;
3.show create tablespa
show create table用於呈現表的基本信息code
show create table user \G;
4.show indexeshtm
show indexes查看索引信息
show indexes from user \G;
5.show table status
show table status用於查看數據表的大小、結構信息
show table status like 'user' \G;
6.show status
show global status
show session status like 'kk';
7.show engine status命令
show engine status命令用查看mysql使用引擎的狀態,爲了方便重定向輸出的文本文件,並\G格式化
mysql -e "show engine innodb status\G" -u[name] -p[password] [database] > /usr/local/status.txt
mysql> SHOW PROCEDURE STATUS\G *************************** 1. row *************************** Db: test Name: sp1 Type: PROCEDURE Definer: testuser@localhost Modified: 2004-08-03 15:29:37 Created: 2004-08-03 15:29:37 Security_type: DEFINER Comment: character_set_client: latin1 collation_connection: latin1_swedish_ci Database Collation: latin1_swedish_ci
mysql> SHOW PROCEDURE STATUS LIKE 'sp1'\G *************************** 1. row *************************** Db: test Name: sp1 Type: PROCEDURE Definer: testuser@localhost Modified: 2004-08-03 15:29:37 Created: 2004-08-03 15:29:37 Security_type: DEFINER Comment: character_set_client: latin1 collation_connection: latin1_swedish_ci Database Collation: latin1_swedish_ci
9.設置數據字符編碼集
在使用數據庫時有時可能須要改變數據的字符編碼
9.1查看當前數據的編碼
//toggle mysql> use xxx; //查看數據庫編碼 mysql>show variables like 'character_set_database'; //update CHARACTER mysql>alter database xxx CHARACTER SET utf-8;
10.獲取數據庫表的schema
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'edu' AND TABLE_NAME = 't_boss';
11.獲取數據表每一列的schema
show columns from pma_designer_coords;