MySQL檢視表占用空間大小

2022-08-12 13:45:13 字數 676 閱讀 9662

需求:我們在選購伺服器硬碟時,通常需要先估算一下資料量。比如我們現在做的專案,百萬級使用者,然後在現有的資料結構中插入一萬條資料,然後根據相應的需求去計算出實際生產中的資料量。

前言:在mysql中有乙個預設的資料表information_schema,information_schema這張資料表儲存了mysql伺服器所有資料庫的資訊。如資料庫名,資料庫的表,表欄的資料型別與訪問許可權等。再簡單點,這台mysql伺服器上,到底有哪些資料庫、各個資料庫有哪些表,每張表的字段型別是什麼,各個資料庫要什麼許可權才能訪問,等等資訊都儲存在information_schema表裡面,所以請勿刪改此表。

**:1,切換資料庫

useinformation_schema;

2,檢視資料庫使用大小

select concat(round(sum(data_length/1024/1024),2),』mb』) as data from tables where table_schema=』db_name』 ;

3,檢視表使用大小

select concat(round(sum(data_length/1024/1024),2),』mb』) as data from tables where table_schema=』db_name』 and table_name=』table_name』;

MySQL檢視表占用空間大小

select table schemaas 資料庫 sum table rows as 記錄數 sum truncate data length 1024 1024,2 as 資料容量 mb sum truncate index length 1024 1024,2 as 索引容量 mb fromi...

mysql怎麼檢視表占用空間大小

1 進去指定schema 資料庫 存放了其他的資料庫的資訊 use information schema 2 查詢所有資料的大小 select concat round sum data length 1024 1024 2 mb as data from tables 3 檢視指定資料庫的大小 比...

sqlserver檢視表占用空間大小

定義表變數 定義表變數 declare ttable name varchar max rows int reserved varchar max data size varchar max index size varchar max unused size varchar max 將表占用情況存...