SELECT SUM(bytes) AS total_size
FROM oceanbase.DBA_DATAFILES
WHERE tenant_id = (SELECT tenant_id FROM oceanbase.__all_tenant WHERE tenant_name = 'A租户');
这条SQL语句的关键在于:
使用oceanbase.DBA_DATAFILES视图来获取数据文件的大小信息。
通过tenant_id来筛选出属于A租户的数据文件。
使用SUM(bytes)来计算所有数据文件的总大小。
请注意,tenant_id是租户的唯一标识符,您需要先确定A租户的tenant_id。上面的查询中使用了子查询(SELECT tenant_id FROM oceanbase.__all_tenant WHERE tenant_name = 'A租户')来获取A租户的tenant_id。
SELECT SUM(bytes) AS total_size
FROM oceanbase.DBA_DATAFILES
WHERE tenant_id = (SELECT tenant_id FROM oceanbase.__all_tenant WHERE tenant_name = 'A租户');
select t.tenant_name,
round(sum(t2.data_size)/1024/1024/1024,2) as data_size_gb,
round(sum(t2.required_size)/1024/1024/1024,2) as required_size_gb
from dba_ob_tenants t,cdb_ob_table_locations t1,cdb_ob_tablet_replicas t2
where t.tenant_id=t1.tenant_id
and t1.svr_ip=t2.svr_ip
and t1.tenant_id=t2.tenant_id
and t1.ls_id=t2.ls_id
and t1.tablet_id=t2.tablet_id
-- and t1.role='leader'
group by t.tenant_name
order by 3 desc;