如果有幸遇到了很老的数据库,而表空间的段管理方式采用的是手动,那么在迁移到到高版本数据库比如12c中需要注意将其调整为自动模式。 这是个容易遗忘的知识点,因为年轻的DBA几乎遇不到使用手工段管理表空间。如果遇上骨灰级表空间,不但是手工端管理模式而且是字典管理模式,那么这会大大影响表空间的性能。
字典管理的表空间可以通过包来转换:
execute dbms_space_admin.tablespace_migrate_to_local('tablespacename');
手工段管理想要转为自动段管理就没有包支持了,可以采用如下步骤来实现:
(1) 模拟创建一个9i时期的手动段管理表空间
SYS@cdb > create tablespace manualsegs9i datafile '/home/oracle/dbfile/manualsegs_9i.dbf' size 10m segment space management manual;
Tablespace created.
(2) 确认表空间是手工段管理模式
SYS@cdb > select segment_space_management from dba_tablespaces where tablespace_name='MANUALSEGS9I';
SEGMEN
------
MANUAL
(3) 在表空间中创建表和索引
SYS@cdb > create table mantab1 (id int) tablespace manualsegs9i;
Table created.
SYS@cdb > create index idx_mantab1 on mantab1(id) tablespace manualsegs9i;
Index created.
(4) 新建自动段管理表空间,该模式为默认
SYS@cdb > create tablespace autosegs12c datafile '/home/oracle/dbfile/autosegs12c.dbf' size 10m;
Tablespace created.
(5) 确认表空间是自动段管理模式
SYS@cdb > select segment_space_management from dba_tablespaces where tablespace_name='AUTOSEGS12C';
SEGMEN
------
AUTO
(6) 将对象移动到新表空间
SYS@cdb > alter table mantab1 move tablespace autosegs12c;
Table altered.
SYS@cdb > alter index idx_mantab1 rebuild online tablespace autosegs12c;
Index altered.
(7) 确认对象位于正确的表空间中
SYS@cdb > select segment_name,tablespace_name from dba_segments where tablespace_name='AUTOSEGS12C';
SEGMENT_NAME TABLESPACE_NAME
-------------------- --------------------
MANTAB1 AUTOSEGS12C
IDX_MANTAB1 AUTOSEGS12C
(8) 删除原始的表空间
SYS@cdb > drop tablespace manualsegs9i including contents and datafiles;
Tablespace dropped.
(9) 重命名为原始的表空间。
SYS@cdb > alter tablespace autosegs12c rename to manualsegs9i;
Tablespace altered.
到此为止演示完毕。
全文完
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29047826/viewspace-1697562/
,如需转载,请注明出处,否则将追究法律责任。