2014-03-26 162 views
2

是否有效的是我的表的數據目錄的大小在Linux機器上的MySQL 5.6比我從information_schema.tables查詢得到的大小大得多?MySQL表的數據目錄大小大小從information_schema.tables計算

在文件系統(/數據/)是11G大小,

雖然下面的查詢返回5G

SELECT sum(ROUND(((DATA_LENGTH + INDEX_LENGTH)/1024/1024),2)) AS size FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='my-table-name 

我缺少的東西?


total   | free   | data   | index_data | 
4597.85937500 | 613.00000000 | 4089.40625000 | 508.45312500 | 
+0

看到答案,返回輸出 –

回答

0

這裏是劇本我用它來找到我的數據庫大小:

SELECT 
table_schema "DB Name", 
Round(Sum(data_length + index_length)/1024/1024, 1) "DB Size in MB" FROM 
information_schema.tables where table_schema ='schema name' ; 

運行此查詢並顯示我們的輸出:

select (sum(data_length) + sum(INDEX_LENGTH))/ 1024/1024 as total, 
    sum(data_free)/ 1024/1024 as free , 
    sum(data_length)/ 1024/1024 as data, 
    sum(INDEX_LENGTH/ 1024/1024) as index_data 
    from information_schema.tables t 
    where t.TABLE_SCHEMA = 'schema name'; 
+0

+ --------------- + -------------- + ---------- ----- + -------------- + |總| |免費|數據| index_data | + --------------- + -------------- + --------------- + - ------------- + | 4597.85937500 | 613.00000000 | 4089.40625000 | 508.45312500 | + --------------- + -------------- + --------------- + - ------------- + – danieln