Obtención de tablespace y status.
$ sqlplus system/**** as sysdba
SQL> select OWNER,TABLESPACE_NAME,STATUS from dba_tables where TABLE_NAME='HISTORY_01';
OWNER TABLESPACE_NAME STATUS
----------------------- ------------------------------ --------
MI_ESQUEMA TBS_HIST_01 VALID
Identificar las tablas e indices que están en el tablespace actual
SQL> select OWNER,INDEX_NAME,TABLESPACE_NAME from dba_indexes where TABLE_NAME='HISTORY_01';
OWNER INDEX_NAME TABLESPACE_NAME
------------------------------ ------------------------------ ------------------------------
MI_ESQUEMA X_HISTORY_01_1 TBS_HIST_01
MI_ESQUEMA X_HISTORY_01_3 TBS_HIST_01
$ sqlplus system/**** as sysdba
SQL> spool truncate.log
SQL> set timing on
SQL> truncate table history_01 drop storage;
SQL> set timing on
SQL> truncate table history_01 drop storage;
Crear un nuevo tablaspace data e index para la tabla
$ sqlplus system/**** as sysdba
SQL> create tablespace TBS_D_NEW_HIST_01 datafile '/datafile/TBS_D_HIST_01.dbf' size 1g autoextend on next 100m; SQL> create tablespace TBS_I_NEW_HIST_01 datafile '/datafile/TBS_I_NEW_HIST_01.dbf' size 1g autoextend on next 100m;
SQL> alter table mi_esquema.history_01 move tablespace TBS_D_NEW_HIST_01;
Mover los indices:
SQL> alter index mi_esquema.X_HISTORY_01_1 rebuild tablespace TBS_I_NEW_HIST_01
SQL> alter index mi_esquema.X_HISTORY_01_3 rebuild tablespace TBS_I_NEW_HIST_01
Verificar que no existan objetos en los tablespaces antiguos.
SQL> select owner, segment_type, segment_name, bytes/1024/1024 MB
from dba_segments
where tablespace_name in ('TBS_D_HIST_01');
where tablespace_name in ('TBS_D_HIST_01');
SQL> select OWNER,INDEX_NAME,TABLESPACE_NAME from dba_indexes where TABLE_NAME='HISTORY_01';
3. Borrar el Tablespace antiguo:
SQL> drop tablespace TBS_D_HIST_01 INCLUDING CONTENTS AND DATAFILES;
SQL> drop tablespace TBS_I_HIST_01 INCLUDING CONTENTS AND DATAFILES;
No hay comentarios:
Publicar un comentario