表空间(下)

WBOY
发布: 2016-06-07 16:06:25
原创
1067 人浏览过

7.表空间的使用大小 -- 查看表空间已使用情况 select a.tablespace_name, round(a.bytes / 1024 / 1024) Sum MB, round((a.bytes - b.bytes) / 1024 / 1024) used MB, round(b.bytes / 1024 / 1024) free MB, round(((a.bytes - b.bytes) / a.bytes), 2) per

7.表空间的使用大小

-- 查看表空间已使用情况
select a.tablespace_name,
round(a.bytes / 1024 / 1024) "Sum MB",
round((a.bytes - b.bytes) / 1024 / 1024) "used MB",
round(b.bytes / 1024 / 1024) "free MB",
round(((a.bytes - b.bytes) / a.bytes), 2) "percent_used"
from (select tablespace_name, sum(bytes) bytes
from dba_data_files
group by tablespace_name) a,
(select tablespace_name, sum(bytes) bytes, max(bytes) largest
from dba_free_space
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name
order by ((a.bytes - b.bytes) / a.bytes) desc;

NOTES:如果运行很久都没得到结果,则查看各个用户下的垃圾箱,
可能是垃圾箱堆积了太多数据导致的
(select * from recyclebin或select * from dba_recyclebin),
然后用下面的命令清理掉该用户的垃圾箱。
(必须各个用户都执行一遍,也可以直接用purge dba_recyclebin命令,
但如果和其他模块一起使用同一数据库,不建议这么操作,因为其他用户的垃圾箱数据可能有用。)
SQL>purge recyclebin;

select file#,name,bytes/1024/1024 from v$tempfile; -- 临时表空间总大小
select tablespace, (sum (blocks))*8/1000 "MB" from v$sort_usage group by tablespace; -- 临时表空间已使用情况


-- 临时表空间使用情况:
Select f.tablespace_name,
sum(f.bytes_free + f.bytes_used) / (1024 * 1024) "total MB",
sum((f.bytes_free + f.bytes_used) - nvl(p.bytes_used, 0)) / (1024 * 1024) "Free MB",
sum(nvl(p.bytes_used, 0)) / (1024 * 1024) "Used MB"
from sys.v_$temp_space_header f,
dba_temp_files d,
sys.v_$temp_extent_pool p
where f.tablespace_name(+) = d.tablespace_name
and f.file_id(+) = d.file_id
and p.file_id(+) = d.file_id
group by f.tablespace_name;

8.修改表的表空间
alter table a move tablespace TBS_DW_YM

9.查询imuse01用户所使用的缺省表空间
select default_tablespace from dba_users where username=’imuse01’;

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!