檢視mysql資料庫所佔空間大小

2021-09-18 06:06:39 字數 711 閱讀 3183

select concat(round(sum(data_length)/1024/1024+sum(index_length)/1024/1024),'m') from information_schema.tables where table_schema='database_name';
由於資料太大了。所以mysql需要**,那前提就是需要知道每個表占用的空間大小。

首先開啟指定的資料庫:

use information_schema;
如果想看指定資料庫中的資料表,可以用如下語句:

select concat(round(sum(data_length/1024/1024),2),'mb') as data from tables where table_schema='aaaa' and table_name='bbbb';
如果想看資料庫中每個資料表的,可以用如下語句:

select table_name,data_length+index_length,table_rows,concat(round((data_length+index_length)/1024/1024,2), 'mb') as data from tables where table_schema='aaaa';

MySQL 檢視資料庫所佔空間大小

在mysql中會有乙個預設的資料庫 information schema,裡面有乙個tables表記錄了所有表的資訊。使用該錶來看資料庫所佔空間大小的 如下 use information schema select table schema,sum data length from tables ...

查詢資料庫表所佔空間

if object id tempdb.tb temp space isnot null drop table tb temp space gocreate table tb temp space name varchar 500 rows int,reserved varchar 50 data ...

檢視 MySQL 資料庫中每個表占用的空間大小

如果想知道mysql資料庫中每個表占用的空間 表記錄的行數的話,可以開啟mysql的 information schema 資料庫。在該庫中有乙個 tables 表,這個表主要字段分別是 table schema 資料庫名 table name 表名 engine 所使用的儲存引擎 tables r...