对于表,请
mydb.mytable运行以下命令:
字节
SELECt (data_length+index_length) tablesizeFROM information_schema.tablesWHERe table_schema='mydb' and table_name='mytable';
基洛比
SELECt (data_length+index_length)/power(1024,1) tablesize_kbFROM information_schema.tablesWHERe table_schema='mydb' and table_name='mytable';
兆字节
SELECt (data_length+index_length)/power(1024,2) tablesize_mbFROM information_schema.tablesWHERe table_schema='mydb' and table_name='mytable';
技嘉
SELECt (data_length+index_length)/power(1024,3) tablesize_gbFROM information_schema.tablesWHERe table_schema='mydb' and table_name='mytable';
一般
这是一个通用查询,其中最大单位显示为TB(TeraBytes)
SELECt CONCAt(FORMAT(DAT/POWER(1024,pw1),2),' ',SUBSTr(units,pw1*2+1,2)) DATSIZE, CONCAt(FORMAT(NDX/POWER(1024,pw2),2),' ',SUBSTr(units,pw2*2+1,2)) NDXSIZE, CONCAt(FORMAT(TBL/POWER(1024,pw3),2),' ',SUBSTr(units,pw3*2+1,2)) TBLSIZEFROM( SELECt DAT,NDX,TBL,IF(px>4,4,px) pw1,IF(py>4,4,py) pw2,IF(pz>4,4,pz) pw3 FROM ( SELECt data_length DAT,index_length NDX,data_length+index_length TBL, FLOOR(LOG(IF(data_length=0,1,data_length))/LOG(1024)) px, FLOOR(LOG(IF(index_length=0,1,index_length))/LOG(1024)) py, FLOOR(LOG(IF(data_length+index_length=0,1,data_length+index_length))/LOG(1024)) pz FROM information_schema.tables WHERe table_schema='mydb' AND table_name='mytable' ) AA) A,(SELECT 'B KBMBGBTB' units) B;
试试看 !!!



