Heim > Datenbank > MySQL-Tutorial > MySQL得到数据库的大小_MySQL

MySQL得到数据库的大小_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Freigeben: 2016-06-01 13:44:00
Original
947 Leute haben es durchsucht

bitsCN.com 1. 命令行方式
前言介绍:
   要知道一个表占用空间的大小,那就相当于是 数据大小+ 索引大小 即可。
   show databases; (查看有多少database, 也叫做table schema; 有点串用)
 
1.1 查看单个database(或是table schema)占用的大小
 
select sum(DATA_LENGTH)+sum(INDEX_LENGTH) from information_schema.tables 
where table_schema='数据库名';  
 
得到的结果是以字节为单位的, 换算成兆的话 除以1024*1024
备注:information_schema库中包含了对整个数据库的很多统计信息,可以通过查看它们,来得到数据库相关的信息
 
省事一点,直接进入information_schema 查看
 
use information_schema; 
接下来忽略索引的大小
1.2 查询所有数据的大小
 
select concat(round(sum(DATA_LENGTH/1024/1024),2),'M') from tables; 
这个需要的时间会长一些
 
1.3 查看数据库的某个表的大小
 
select concat(round(sum(DATA_LENGTH/1024/1024),2),'M') from tables where table_schema=’数据库名’AND table_name=’表名’; 
 
 
 
2. 软件查看方式
可以安装PhpMyAdmin 也可以看到

摘自 oscar999的专栏 bitsCN.com

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage