表空间脚本

--表空间脚本


创建表空间:
create tablespace dbs_dperf_pt datafile '/usr3/oradata3/userdata/dbs_dperf_pt01.dbf'  size 20000M   autoextend off;
alter tablespace dbs_dperf_pt add datafile '/usr3/oradata1/userdata/dbs_dperf_pt02.dbf' size 20000M  autoextend off;
alter tablespace dbs_dperf_pt add datafile '/usr3/oradata2/userdata/dbs_dperf_pt03.dbf' size 20000M  autoextend off;
alter tablespace dbs_dperf_pt add datafile '/usr3/oradata3/userdata/dbs_dperf_pt04.dbf' size 20000M  autoextend off;
alter tablespace dbs_dperf_pt add datafile '/usr3/oradata1/userdata/dbs_dperf_pt05.dbf' size 20000M  autoextend off;
alter tablespace dbs_dperf_pt add datafile '/usr3/oradata2/userdata/dbs_dperf_pt06.dbf' size 20000M  autoextend off;
alter tablespace dbs_dperf_pt add datafile '/usr3/oradata3/userdata/dbs_dperf_pt07.dbf' size 20000M  autoextend off;
alter tablespace dbs_dperf_pt add datafile '/usr3/oradata1/userdata/dbs_dperf_pt08.dbf' size 20000M  autoextend off;
alter tablespace dbs_dperf_pt add datafile '/usr3/oradata2/userdata/dbs_dperf_pt09.dbf' size 20000M  autoextend off;
alter tablespace dbs_dperf_pt add datafile '/usr3/oradata3/userdata/dbs_dperf_pt10.dbf' size 20000M  autoextend off;

查询表空间利用率:
(1)
select
a.a1 tablespace_name,
b.b2/1024/1024 sizeM,
(b.b2-a.a2)/1024/1024 usedM,
substr((b.b2-a.a2)/b.b2*100,1,5) rate
from
(select   tablespace_name a1, sum(nvl(bytes,0)) a2 from dba_free_space group by tablespace_name) a,
(select tablespace_name b1,sum(bytes) b2 from dba_data_files group by tablespace_name) b,
(select tablespace_name c1,contents c2,extent_management c3  from dba_tablespaces) c
where a.a1=b.b1 and c.c1=b.b1
(2)
select 
    total.tablespace_name,  
    round(total.MB,2) as Total_MB,  
    round(total.MB-free.MB, 2) as Used_MB,  
    round((1-free.MB/total.MB)*100, 2) as Used_Pct  
from 
    (select tablespace_name, sum(bytes)/1024/1024 as MB from dba_free_space group by tablespace_name) free,  
    (select tablespace_name, sum(bytes)/1024/1024 as MB from dba_data_files group by tablespace_name) total  
where 
    free.tablespace_name=total.tablespace_name;

增加表空间:
alter tablespace DBS_DPERF_PT add datafile '/usr3/oradata4/userdata/dbs_dperf_pt51.dbf' size 20000M autoextend off;

清空表分区:

alter table CDL_RAW_1X_12101_HWV99 truncate partition cdl1x_12101_hwv99_120100 ;

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值