1、表空间状态的查看
dba_data_files ->
2、修改表空间状态:
alter tablespace users offline;
select tablespace_name,status,online_status from dba_data_files;
3、数据文件若要更改为脱机状态(offline),需要在归档模式下进行,且Undo表空间、系统表空间、临时表空间不能脱机(数据文件在read write状态下时)
Alter database datafile 4 offline;
4、删除表空间
drop database xxx
drop database xxx including contents
drop database xxx including contents and datafiles
例子:
(1)创建表空间
create tablespace a1 datafile '/u01/oracle/oradata/wyzc10g/a1.dbf' size 10m;
(2)在该表空间上创建表
create table scott.a1 tablespace a1 as select * from scott.emp
(3)删除表空间
drop tablespace a1;
当表空间中包含有内容时报错:ORA-01549: tablespace not empty, use INCLUDING CONTENTS option
(4)连内容一起删
drop tablespace a1 including contents;
文件还在:
SQL> ho ls /u01/oracle/oradata/wyzc10g/a1.dbf;
/u01/oracle/oradata/wyzc10g/a1.dbf
若还需要用到这个数据文件去创建表空间,则需要使用reuse参数
create tabelspace a1 datafile '/u01/oracle/oradata/wyzc10g/a1.dbf' size 10m;
(5)连同表,数据文件一起删
Drop table space a1 including contents and datafiles;
5、表空间不足时的处理
i.大表表空间只有一个数据文件:
alter tablespace b1 resize 10m
ii.小表表空间,需要resize 数据文件