您的位置:首页 > 其它

查看表空间利用率及相关及脚本

2010-05-04 13:30 127 查看
-- 查看表空间利用率

select
b.file_id file_id,
b.tablespace_name,
b.bytes,
b.maxbytes,
(b.bytes-sum(nvl(a.bytes,0))) used,
sum(nvl(a.bytes,0)) unused,
sum(nvl(a.bytes,0))/(b.bytes)*100 percentage
from dba_free_space a,dba_data_files b
where a.file_id=b.file_id
group by b.tablespace_name,b.file_id,b.bytes,b.maxbytes
order by b.file_id;

or

select tablespace_name,sum(bytes)/1024/1024/1024 GB
from dba_data_files group by tablespace_name
union all
select tablespace_name,sum(bytes)/1024/1024/1024 GB
from dba_temp_files group by tablespace_name order by GB;

-- 查看数据文件表空间的对应关系

select t.name,t1.name
from v$tablespace t,
v$datafile t1
where t.ts# = t1.ts#
;

-- 创建表空间

1.表空间

create tablespace tablespacename datafile 'datafilepath/datafilename ' size 10g;

--删除

drop tablespace tablespacename including contents and datafiles;--删除表空间及操作系统的数据文件

2.临时表空间

create temporary tablespace TEMP2 TEMPFILE ''/home2/oracle/oradata/sysmon/temp02.dbf'' SIZE 10

g;

-- 删除

drop tablespace temp including contents and datafiles;--删除临时表空间及操作系统的数据文件

3.undo表空间

create undo tablespace undotbs_01
datafile '/u01/oracle/rbdb1/undo0201.dbf' size 2g;

-- 我们创建表空间时要以tbs_业务类型进行命名.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: