欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

SQL查询数据库所有表的数据量及占用空间大小

程序员文章站 2024-03-21 14:23:22
...
/*查询数据库所有表的数据量及占用空间大小*/
SELECT t.table_name AS "数据库表名"
       ,t.num_rows AS "行数"
       ,round((nvl(t.num_rows,0) * nvl(t.avg_row_len,0)) / 1024 / 1024,2) || ' M' AS "占用空间"
       ,to_char(SYSDATE, 'yyyy-mm-dd hh24:mi:ss') AS "创建时间"
  FROM user_tables t
 WHERE 1 = 1
   AND nvl(t.num_rows, 0) <> 0
 ORDER BY (nvl(t.num_rows,0) * nvl(t.avg_row_len,0)) DESC;