Home > Database > Mysql Tutorial > 表空间(下)

表空间(下)

WBOY
Release: 2016-06-07 16:06:25
Original
1138 people have browsed it

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’;

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template