mysql;
SELECT
table_name,
concat(
round((DATA_LENGTH / 1024 / 1024), 2),
'M'
) AS size,
table_rows
FROM
information_schema. TABLES
ORDER BY
table_rows DESC
postgresql;
SELECT
table_schema,
TABLE_NAME,
reltuples,
pg_size_pretty (
pg_total_relation_size (
'"' || table_schema || '"."' || table_name || '"'
)
)
FROM
pg_class,
information_schema. TABLES
WHERE
relname = TABLE_NAME
ORDER BY
reltuples DESC
oracle;
-- 查记录条数可以用如下语句:
SELECT
* from user_tables t
WHERE
t.NUM_ROWS IS NOT NULL
ORDER BY
t.NUM_ROWS DESC;
-- 表实际使用的空间:
SELECT
num_rows * avg_row_len
FROM
user_tables;