0. 테이블 스페이스 삭제
drop tablespace inventory including contents and datafiles;
drop tablespace users01 including contents and datafiles;
drop tablespace users02 including contents and datafiles;
drop tablespace users03 including contents and datafiles;
drop tablespace users04 including contents and datafiles;
1. 파일 추가
create tablespace users01
datafile '/u01/app/oracle/oradata/devdb/users01.dbf' size 10m;
alter tablespace users01
add datafile '/u01/app/oracle/oradata/devdb/users01_2.dbf' size 10m;
2. 파일 삭제
alter tablespace users01
drop datafile '/u01/app/oracle/oradata/devdb/users01.dbf';
--> 실패 (데이터 파일이 비어 있는 경우에만 삭제가 가능함)
alter tablespace users01
drop datafile '/u01/app/oracle/oradata/devdb/users01_2.dbf';
alter database datafile
'/u01/app/oracle/oradata/devdb/users01.dbf' resize 20m;
3. 파일 크기 조정
alter database datafile
'/u01/app/oracle/oradata/devdb/users01.dbf' resize 5m;
alter database datafile
'/u01/app/oracle/oradata/devdb/users01.dbf' resize 20m;
4. 파일 크기 자동조정 설정
alter database datafile
'/u01/app/oracle/oradata/devdb/users01.dbf' autoextend on next 10m maxsize 200m;
5. 파일 위치 또는 이름 변경
(1) 일반 Tablespace일 경우
SQL> !mkdir /u01/app/oracle/oradata/devdb/new_disk
SQL> alter tablespace users01 offline;
SQL> !mv /u01/app/oracle/oradata/devdb/users01.dbf /u01/app/oracle/oradata/devdb/new_disk
SQL> alter tablespace users01 rename datafile
'/u01/app/oracle/oradata/devdb/users01.dbf' to
'/u01/app/oracle/oradata/devdb/new_disk/users01.dbf';
SQL> alter tablespace users01 online;
(2) System Tablespace일 경우
SQL> !mkdir /u01/app/oracle/oradata/devdb/system_disk
SQL> shutdown immediate
SQL> !mv /u01/app/oracle/oradata/devdb/system01.dbf /u01/app/oracle/oradata/devdb/system_disk
SQL> startup mount
SQL> alter database rename file
'/u01/app/oracle/oradata/devdb/system01.dbf' to
'/u01/app/oracle/oradata/devdb/system_disk/system01.dbf';
SQL> alter database open;