测试场景下,使用的oralce遇到表空间的占用超大,能够采用以下的方式进行空间的清理sql
首先使用sqlplus链接数据库
sqlplus sys/password@orcl as sysdba 之类进行数据库的链接没而后进行以下的操做数据库
##建立表空间
对于本身的测试库和表等最好都创建本身的表空间,以方便清理和删除oracle
create tablespace abc datafile '/opt/oracle/app/oradata/orcl/users02.dbf' size 1024m autoextend on next 100m maxsize 10240m extent management local; 建立表空间app
##查看表空间的状况
oracle查询表空间文件所在路径 测试
select * from dba_data_files
经过这个命令能够查看各表空间所在的路径位置spa
##temp表空间的重建
+ 新建1个操作系统
当数据库进行索引重建,或者大量数据导入导出时,会使得temp表空间暴增,极可能撑满数据文件,由于数据库安装的时候,temp表空间默认很自由一个数据文件
而且数据库中单个数据文件最大只能自增到32G,当超过32G时就不可用了,为了防止此故障发生,在作索引重建或者大量数据导入导出时,须要关注temp表空间
的增加状况,temp表空间过大时,可经过以下方法重建
SQL> create temporary tablespace temp2 tempfile 'C:\oracle\product\10.2.0\oradata\ORCL\temp2.dbf' size 200M autoextend off;
SQL> alter database default temporary tablespace temp2;
SQL> drop tablespace temp;
或者SQL> drop tablespace temp including contents and datafiles cascade constraints(完全删除包括操做系统中的临时表空间的数据文件)
最后在操做系统上把temp的文件删除,就能够释放空间。索引
+ 还原回来table
还能够改成原来的temp
SQL> create temporary tablespace temp tempfile 'C:\oracle\product\10.2.0\oradata\ORCL\temp.dbf' size 200M autoextend off;
SQL> alter database default temporary tablespace temp;
SQL> drop tablespace temp2;
最后在操做系统上把temp的文件删除,就能够释放空间。file
如上就能够把很是大temp表空间清理掉
##system表空间用满解决 alter database datafile 'C:\oracle\product\10.2.0\oradata\ORCL\system01.dbf' autoextend on; alter database datafile 'C:\oracle\product\10.2.0\oradata\ORCL\system01.dbf' resize 2096M;若是出现“ORA-03297: 文件包含在请求的 RESIZE 值之外使用的数据”这个错误,调整表空间的大小便可,完成后便可释放多余的表空间