在Oracle数据库中,查询表空间的大小可以通过以下SQL语句实现:
SELECT
df.tablespace_name AS "Tablespace",
ROUND(SUM(df.bytes) / 1024 / 1024, 2) AS "Total_MB",
ROUND(SUM(free.bytes) / 1024 / 1024, 2) AS "Free_MB",
ROUND(NVL((SUM(free.bytes) / SUM(df.bytes)), 0) * 100, 2) AS "Pct_Free"
FROM
dba_free_space free
RIGHT JOIN
dba_data_files df ON free.tablespace_name = df.tablespace_name
GROUP BY
df.tablespace_name;
在MySQL数据库中,查询表的大小可以使用以下SQL语句:
SELECT
table_schema AS "Database",
table_name AS "Table",
ROUND((data_length + index_length) / 1024 / 1024, 2) AS "Size_MB"
FROM information_schema.TABLES
ORDER BY (data_length + index_length) DESC;
这些查询会返回数据库表空间或表的总大小,包括已使用的空间和空闲空间,并以MB为单位进行了格式化。