mysql 表空間及索引的檢視方法

2022-09-27 06:18:07 字數 1402 閱讀 6611

1.檢視索引

(1)單位是gb

select concat(round(sum(index_length)/(1024*1024*1024), 2), ' gb') as 'total index size' from information_schema.tables where table_schema like 'database';

+------------------+

| total index size |

+------------------+

| 1.70 gb |

+------------------+

(2)單位是mb

select concat(round(sum(index_length)/(1024*1024), 2), ' mwww.cppcns.comb') as 'total index size' from information_schema.tables where table_schema like 'database';

其中「database」為你所要檢視的資料庫

2.檢視表空間

select concat(round(sum(data_length)/(1024*1024*1024), 2), ' gb') as 'total data size'

from information_schema.tables where table_schema like 'database';

+-----------------+

| total data size |

+-----------------+

| 3.01 gb |

+-----------------+

3.檢視資料庫中所有表的資訊

select concat(table_schema,'.',table_name)程式設計客棧 as 'table namewww.cppcns.com',

concat(round(table_rows/1000000,2),'m') as 'number of rows',

concat(round(data_length/(1024*1024*1024),2),'g') as 'data size',

concat(round(index_length/(1024*1024*1024),2),'g') as 'index size' ,

concat(round((data_length+index_length)/(1024*1024*102程式設計客棧4),2),'g') as'total'from information_schema.tables mosepfwhere table_schema like 'database';

本文標題: mysql 表空間及索引的檢視方法

本文位址:

mysql 表空間及索引大小的檢視

table schema 是資料庫名 mysql select concat table schema,table name as table name concat round table rows 1000000,2 m as number of rows concat round data l...

mysql表空間及索引大小的檢視

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

mysql表檢視方法 檢視mysql表的方法

安裝好mysql後,配製檔案應該在 usr local mysql share mysql目錄中,配製檔案有幾個,有my huge.cnf my medium.cnf my large.cnf my small.cnf,不同的流量的 和不同配製的伺服器環境,當然需要有不同的配製檔案了。一般的情況下,...