一、MySQL
select table_name, #表名
sum(data_length+index_length)/(1024)/(1024) as total_mb, #总大小MB
sum(data_length)/(1024)/(1024) as data_mb, #数据文件大小MB
sum(index_length)/(1024)/(1024) as index_mb #索引大小MB
from information_schema.tables
where table_schema='ABC' group by table_name #ABC为数据库名称
二、SqlServer
select name, #数据文件名称
convert(float,size) * (8192.0/1024.0)/1024.0 #转为MB
from bserp3.dbo.sysfiles
三、Oracle
SELECT a.tablespace_name "表空间名",
total "表空间大小",
free "表空间剩余大小",
(total - free) "表空间使用大小",
total / (1024 * 1024 * 1024) "表空间大小(G)",
free / (1024 * 1024 * 1024) "表空间剩余大小(G)",
(total - free) / (1024 * 1024 * 1024) "表空间使用大小(G)",
round((total - free)