--表空间脚本
创建表空间:
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 ;