Dưới đây là các truy vấn có tổ chức hơn đối với THÔNG TIN_SCHema
Kích thước bằng công cụ lưu trữ
SELECT
    IFNULL(B.engine, 'Total') "Storage Engine",
    CONCAT(LPAD(REPLACE(FORMAT(B.DSize / POWER(1024, pw), 3), ',', ''), 17, ' '), ' ', SUBSTR(' KMGTP', pw + 1, 1), 'B') "Data Size",
    CONCAT(LPAD(REPLACE( FORMAT(B.ISize / POWER(1024, pw), 3), ',', ''), 17, ' '), ' ', SUBSTR(' KMGTP', pw + 1, 1), 'B') "Index Size",
    CONCAT(LPAD(REPLACE( FORMAT(B.TSize / POWER(1024, pw), 3), ',', ''), 17, ' '), ' ', SUBSTR(' KMGTP', pw + 1, 1), 'B') "Table Size" 
FROM
    (SELECT
            engine,
            SUM(data_length) DSize,
            SUM(index_length) ISize,
            SUM(data_length + index_length) TSize 
        FROM
            information_schema.tables 
        WHERE
            table_schema NOT IN ('mysql', 'information_schema', 'performance_schema')
            AND engine IS NOT NULL 
        GROUP BY engine WITH ROLLUP
    ) B,
    (SELECT 3 pw) A 
ORDER BY TSize;
Kích thước theo cơ sở dữ liệu
SELECT
    dbname,
    Concat(Lpad(Format(sdsize / Power(1024, pw), 3), 17, ' '), ' ', Substr(' KMGTP', pw + 1, 1), 'B') "Data Size",
    Concat(Lpad(Format(sxsize / Power(1024, pw), 3), 17, ' '), ' ', Substr(' KMGTP', pw + 1, 1), 'B') "Index Size",
    Concat(Lpad(Format(stsize / Power(1024, pw), 3), 17, ' '), ' ', Substr(' KMGTP', pw + 1, 1), 'B') "Total Size" 
FROM
    (SELECT
            Ifnull(db, 'All Databases') DBName,
            Sum(dsize) SDSize,
            Sum(xsize) SXSize,
            Sum(tsize) STSize 
        FROM (SELECT
                    table_schema DB,
                    data_length DSize,
                    index_length XSize,
                    data_length + index_length TSize 
                FROM information_schema.tables 
                WHERE table_schema NOT IN ('mysql','information_schema','performance_schema')
            ) AAA 
        GROUP BY db WITH rollup
    ) AA,
    (SELECT 3 pw) BB 
ORDER BY ( sdsize + sxsize ); 
Kích thước theo cơ sở dữ liệu / công cụ lưu trữ
SELECT
    Statistic,
    DataSize "Data Size",
    IndexSize "Index Size",
    TableSize "Table Size" 
FROM
    (SELECT
            IF(ISNULL(table_schema) = 1, 10, 0) schema_score,
            IF(ISNULL(engine) = 1, 10, 0) engine_score,
            IF(ISNULL(table_schema) = 1, 'ZZZZZZZZZZZZZZZZ', table_schema) schemaname,
            IF(ISNULL(B.table_schema) + ISNULL(B.engine) = 2, "Storage for All Databases", IF(ISNULL(B.table_schema) + ISNULL(B.engine) = 1, CONCAT("Storage for ", B.table_schema), CONCAT(B.engine, " Tables for ", B.table_schema))) Statistic,
            CONCAT(LPAD(REPLACE(FORMAT(B.DSize / POWER(1024, pw), 3), ',', ''), 17, ' '), ' ', SUBSTR(' KMGTP', pw + 1, 1), 'B') DataSize,
            CONCAT(LPAD(REPLACE( FORMAT(B.ISize / POWER(1024, pw), 3), ',', ''), 17, ' '), ' ', SUBSTR(' KMGTP', pw + 1, 1), 'B') IndexSize,
            CONCAT(LPAD(REPLACE(FORMAT(B.TSize / POWER(1024, pw), 3), ',', ''), 17, ' '), ' ', SUBSTR(' KMGTP', pw + 1, 1), 'B') TableSize 
        FROM
            (SELECT
                    table_schema,
                    engine,
                    SUM(data_length) DSize,
                    SUM(index_length) ISize,
                    SUM(data_length + index_length) TSize 
                FROM
                    information_schema.tables 
                WHERE
                    table_schema NOT IN ('mysql', 'information_schema', 'performance_schema')
                    AND engine IS NOT NULL 
                GROUP BY
                    table_schema, engine WITH ROLLUP
            ) B,
            (SELECT 3 pw) A
    ) AA 
ORDER BY schemaname, schema_score, engine_score;
CAUPAT
Trong mỗi ba (3) truy vấn, bạn sẽ thấy (SELECT 3 pw). Chữ pwviết tắt của Power Of 1024 để hiển thị kết quả theo các đơn vị cụ thể:
(SELECT 0 pw) sẽ hiển thị Báo cáo theo byte 
(SELECT 1 pw) sẽ hiển thị Báo cáo theo KiloBytes 
(SELECT 2 pw) sẽ hiển thị Báo cáo trong MegaBytes 
(SELECT 3 pw) sẽ hiển thị Báo cáo trong GigaBytes 
(SELECT 4 pw) sẽ hiển thị Báo cáo trong TeraBytes 
(SELECT 5 pw) sẽ hiển thị Báo cáo trong PetaBytes (vui lòng liên hệ với tôi nếu bạn chạy cái này) 
Đây là một truy vấn báo cáo với định dạng ít hơn một chút trong KB:
SELECT
    IFNULL(db, 'Total') "Database",
    datsum / power(1024, pw) "Data Size",
    ndxsum / power(1024, pw) "Index Size",
    totsum / power(1024, pw) "Total" 
FROM
    (
        SELECT
            db,
            SUM(dat) datsum,
            SUM(ndx) ndxsum,
            SUM(dat + ndx) totsum 
        FROM
            (
                SELECT table_schema db, data_length dat, index_length ndx 
                FROM information_schema.tables 
                WHERE engine IS NOT NULL AND table_schema NOT IN ('information_schema', 'mysql')
            ) AA 
        GROUP BY db WITH ROLLUP
    ) A,
    (SELECT 1 pw) B;
Hãy thử một lần !!!