24.Show table status解析
- show table status主要是用来查看一个表的状态信息
- 语法:
SHOW TABLE STATUS [{FROM | IN} db_name] [LIKE 'pattern' | WHERE expr]
也可以使用以下命令进行查看: mysqlshow --status db_name command
输出:
show table status from liulin\G; *************************** 1. row *************************** Name: produce ##表名 Engine: InnoDB ##存储引擎名字 Version: 10 ## The version number of the table's.frm
file Row_format: Dynamic ##行记录格式,对于MyIsam,它可能是Dynamic,对于Innodb引擎,它可能是(Redundant
orCompact
),这几种行记录格式区别后面会做介绍 Rows: 10437 ##该值对于MyIsam存储引擎是一个精确值,但对于innodb和其他存储引擎就是一个近似值,且与实际有这40%~50%之间的误差 Avg_row_length: 36 ##平均每行的长度(单位是字节)
Data_length: 376832
##对于myisam来说,它表示数据文件的长度(单位:字节),对于Innodb来说,它表示聚集索引分配的大约的空间量(单位:字节),具体是聚集索引(数据页数量)乘以每页的大小 Max_data_length: 0 ##这个是只针对Myisam存储引擎,表示该表最大可以容纳多少字节 Index_length: 180224 ##表示索引的长度(占用空间的大小),单位是字节 Data_free: 0 ##分配但未使用的字节数 Auto_increment: NULL Create_time: 2021-04-06 09:51:14 ##表的创建日期 Update_time: NULL Check_time: NULL Collation: utf8mb4_general_ci ##表默认排序 Checksum: NULL Create_options: Comment:
###这里有个问题:表produce里面的数据是使用存储过程函数进行存储的,这里显示的行数是1w行,但是实际上只有100行数据,没有找到原因。。。。。。
以上参考Mysql的官方文档
https://dev.mysql.com/doc/refman/5.7/en/show-table-status.html
补充:
(1)、show table status from db_name
查询db_name 数据库里所有表的信息
(2)、show table status from db_name like 'esf_seller_history'\G;
查询db_name 里 esf_seller_history 表的信息
(3)、show table status from db_name LIKE 'uc%'
查询db_name 数据库里表名以uc开头的表的信息
select table_schema as '数据库',table_name as '表名',table_rows as '记录数',round(data_length/1024/1024) as'数据 容量MB',round(index_length/1024/1024,2) as '索引容量MB' from information_schema.tables where table_schema='liulin';