平面设计师必备网站,大连培训通网站建设,上海民营企业500强,平面设计投稿平台一、information_schema数据库
1.1、概述 information_schema数据库是MySQL出厂默认带的一个数据库#xff0c;不管我们是在Linux中安装MySQL还是在Windows中安装MySQL#xff0c;安装好后都会有一个数据库information_schema#xff0c;这个库中存放了其他库的所有信息。 …一、information_schema数据库
1.1、概述 information_schema数据库是MySQL出厂默认带的一个数据库不管我们是在Linux中安装MySQL还是在Windows中安装MySQL安装好后都会有一个数据库information_schema这个库中存放了其他库的所有信息。 1.2、关键表 schemata表这个表里面主要是存储在mysql中的所有的数据库的信息。tables表这个表里存储了所有数据库中的表的信息包括每个表有多少个列等信息。columns表这个表存储了所有表中的表字段信息。statistics表存储了表中索引的信息。user_privileges表存储了用户的权限信息。schema_privileges表存储了数据库权限。table_privileges表存储了表的权限。column_privileges表存储了列的权限信息。character_sets表存储了mysql可以用的字符集的信息。collations表提供各个字符集的对照信息。collation_character_set_applicability表相当于collations表和character_sets表的前两个字段的一个对比记录了字符集之间的对照信息。table_constraints表这个表主要是用于记录表的描述存在约束的表和约束类型。key_column_usage表记录具有约束的列。routines表记录了存储过程和函数的信息不包含自定义的过程或函数信息。views表记录了视图信息需要有show view权限。triggers表存储了触发器的信息需要有super权限。 二、常用功能
2.1、查询所有数据库中所有表占据的空间
use information_schema;select concat(round(sum(data_length/1024/1024),2),MB) as MB, concat(round(sum(data_length/1024/1024/1024),2),GB) as GB
from tables; 2.2、查询指定数据库占据的空间
select concat(round(sum(data_length/1024/1024),2),MB) as MB, concat(round(sum(data_length/1024/1024/1024),2),GB) as GB
from tables
where table_schema vhr; 2.3、查询指定数据库的指定表占据的空间
select concat(round(sum(data_length/1024),2),KB) as KB, concat(round(sum(data_length/1024/1024),2),MB) as MB, concat(round(sum(data_length/1024/1024/1024),2),GB) as GB
from tables
where table_schema vhr
and table_name user; 2.4、查询指定数据库的指定表的索引占据的空间
2.4.1、当前数据库中的表 2.4.2、user表中的索引信息 2.4.3、user表中索引所占空间大小 2.5、参考
https://blog.csdn.net/u011334621/article/details/53066818