ITPub博客

首页 > 数据库 > Oracle > 表空间大小、某个表空间上的所有对象大小、某个用户下所有表记录数查询语句

表空间大小、某个表空间上的所有对象大小、某个用户下所有表记录数查询语句

原创 Oracle 作者:laojiangjiji 时间:2018-01-01 16:28:28 0 删除 编辑
1、查询某个表空间上对象的大小
select owner,segment_name,segment_type,sum(bytes)/1024/1024 as segment_size
  from dba_segments
where tablespace_name='xxx'
group by owner,segment_name,segment_type
order by 4;

2、查询某个用户下所有表的记录总数数量的语句生成语句
select 'select '''||table_name||''' as table_name,count(*) as cnt from '||table_name||' union all ' from all_tables where owner='xxx';

3、查询表空间的大小及使用大小
SELECT a.tablespace_name,
total / (1024 * 1024 * 1024) "大小(G)", 
free / (1024 * 1024 * 1024) "剩余大小(G)", 
(total - free) / (1024 * 1024 * 1024) "使用大小(G)", 
round((total - free) / total, 4) * 100 "使用率 %" 
FROM (SELECT tablespace_name, SUM(bytes) free 
FROM dba_free_space 
GROUP BY tablespace_name) a, 
(SELECT tablespace_name, SUM(bytes) total 
FROM dba_data_files 
GROUP BY tablespace_name) b 
WHERE a.tablespace_name = b.tablespace_name;

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29911917/viewspace-2149561/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-09-23

  • 博文量
    35
  • 访问量
    48739