常
⽤
M
y
S
q
l
脚
本
#hrg
1987
/
5544739
#
查
询
指
定
表
所
有
的
字
段
信
息
select
*
from
information_schema.COLUMNS
where
TABLE_NAME='comment';
select
*
from
information_schema.COLUMNS
where
TABLE_NAME='report';
select
*
from
information_schema.COLUMNS
where
TABLE_NAME='vip_exclusive';
#
查
询
默
认
引
擎
SELECT
@@default_storage_engine;
show
table
status
like
'sources';
--
修
改
存
储
引
擎
#
ALTER
TABLE
t
ENGINE
=
InnoDB;
#
查
看
MySQL
数据
保
存
在哪
⾥
show
variables
like
'data%';
#
MySQL
中
可
通过
如
下
命
令
查
看
⻚
的
⼤
⼩
show
variables
like
'innodb_page_size';
--
慢
查
询
#
具
体
指
运
⾏
时
间
超
过
long_query_time
值
的
SQL
,
则
会
被记
录
到
慢
查
询
⽇
志
中
。
show
variables
like
'long_query_time';
#
查
看
开
启
状
态
SHOW
VARIABLES
LIKE
'%slow_query_log%';
show
status
like
'innodb_row_lock%';
#
查
询
mysql
进
程
,
观
察
锁
问题
show
processlist
;
--
Show
Profile
分
析查
询
#
是
否
⽀
持
,
看看
当
前
的
mysql
版
本是
否
⽀
持
Show
variables
like
'profiling';
--
查
询
innodb
引
擎
下
各
个
表
的
索
引
结
构树
的
⾼
度
select
b.name,a.NAME,INDEX_ID,TYPE,a.SPACE,a.PAGE_NO
from
information_schema.INNODB_SYS_INDEXES
a,information_schema.INNODB_SYS_TABLES
b
where
a.TABLE_ID
=
b.TABLE_ID
and
a.SPACE<>
10
;
#
性
能
瓶
颈
定
位
#
show
status
——
显
示
状
态
信
息
(
扩
展
show
status
like
‘
XXX
’
)
#
show
variables
——
显
示
系统
变
量
(
扩
展
show
variables
like
‘
XXX
’
)
#
show
innodb
status
——
显
示
InnoDB
存
储
引
擎
的
状
态