[현업에서 테이블스페이스 생성 시 주의사항]
- 최신 버전일수록 default를 옵션으로 해서 생성합니다.
create tablespace ts01
datafile '/home/oracle/ts01.dbf' size 100m;
2. 테이블과 인덱스는 별도의 테이블스페이스에 구성합니다.
3. undo 테이블스페이스와 temp 테이블스페이스의 크기를 넉넉히 설정합니다.
4. system tablespace와 sysaux 테이블스페이스가 full이 되지 않도록 미리미리 공간 추가를 합니다.
[실습1] hr 계정의 테이블과 인덱스가 별도의 테이블 스페이스에 분리되도록 아래의 테이블 스페이스를 만들고 분리하시오
create tablespace hr_data_ts
datafile '/u01/app/oracle/oradata/ORA19/hr_data_ts01.dbf' size 1024m;
create tablespace hr_index_ts
datafile '/u01/app/oracle/oradata/ORA19/hr_index_ts01.dbf' size 1024m;
select 'alter table hr.' || table_name || ' move tablespace hr_data_ts;'
from dba_tables
where owner='HR' and table_name !='COUNTRIES';
alter table hr.DEPARTMENTS move tablespace hr_data_ts;
alter table hr.EMPLOYEES move tablespace hr_data_ts;
alter table hr.JOBS move tablespace hr_data_ts;
alter table hr.JOB_HISTORY move tablespace hr_data_ts;
alter table hr.LOCATIONS move tablespace hr_data_ts;
alter table hr.REGIONS move tablespace hr_data_ts;
select table_name, tablespace_name
from dba_tables
where owner='HR';
select 'alter index hr.' || index_name || ' rebuild online tablespace hr_index_ts;'
from dba_indexes
where owner='HR' and table_name !='COUNTRIES';
alter index hr.DEPT_ID_PK rebuild online tablespace hr_index_ts;
alter index hr.DEPT_LOCATION_IX rebuild online tablespace hr_index_ts;
alter index hr.EMP_EMAIL_UK rebuild online tablespace hr_index_ts;
alter index hr.EMP_EMP_ID_PK rebuild online tablespace hr_index_ts;
alter index hr.EMP_DEPARTMENT_IX rebuild online tablespace hr_index_ts;
alter index hr.EMP_JOB_IX rebuild online tablespace hr_index_ts;
alter index hr.EMP_MANAGER_IX rebuild online tablespace hr_index_ts;
alter index hr.EMP_NAME_IX rebuild online tablespace hr_index_ts;
alter index hr.EMP_HIRE_DATE_IX rebuild online tablespace hr_index_ts;
alter index hr.JOB_ID_PK rebuild online tablespace hr_index_ts;
alter index hr.JHIST_EMP_ID_ST_DATE_PK rebuild online tablespace hr_index_ts;
alter index hr.JHIST_JOB_IX rebuild online tablespace hr_index_ts;
alter index hr.JHIST_EMPLOYEE_IX rebuild online tablespace hr_index_ts;
alter index hr.JHIST_DEPARTMENT_IX rebuild online tablespace hr_index_ts;
alter index hr.LOC_ID_PK rebuild online tablespace hr_index_ts;
alter index hr.LOC_CITY_IX rebuild online tablespace hr_index_ts;
alter index hr.LOC_STATE_PROVINCE_IX rebuild online tablespace hr_index_ts;
alter index hr.LOC_COUNTRY_IX rebuild online tablespace hr_index_ts;
alter index hr.REG_ID_PK rebuild online tablespace hr_index_ts;
select index_name, tablespace_name
from dba_indexes
where owner='HR';
💡 오렌지 사용 시 팁 !
- 테이블명에 커서를 놓고
alt+c를 누르면 테이블 description을 볼 수 있음
- 특정 스크립트만 수행하고 싶다면 스크립트를 선택하고
ctrl + l을 누르면 됨
[실습2] undo tablespace 와 temp 테이블 스페이스의 여유공간을 확인하시오

[실습3] system 과 sysaux 테이블 스페이스의 여유공간을 확인합니다.

alter tablespace sysaux
add datafile '/u01/app/oracle/oradata/ORA19/sysaux02.dbf' size 100m;
