oracle 10G 表空间迁移 索引需要重建

简介:

昨天进行了表空间迁移的维护,维护后出现一个问题:MYTEST用户下的表表空间迁移后索引存在失效。
针对该问题和其他DBA进行了一些沟通,大家理解并不统一。后通过实际测试发现,表空间迁移后没有数据的表索引正常,但有数据的表的相关索引确实会失效,
解决的方法是REBUILD索引(今早rubuild MYTEST下的所有索引,通过select INDEX_NAME,status from user_indexes确认status均为VALID的正常状态)。

进一步查找资料发现:
Moving a table changes the rowids of the rows in the table. This causes indexes on the table to be marked UNUSABLE, 
and DML accessing the table using these indexes will receive an ORA-01502 error. The indexes on the table must be dropped or rebuilt. 
Likewise, any statistics for the table become invalid and new statistics should be collected after moving the table.
移动表会导致行的rowid变化,导致该表上面的index不可用,即标记为UNUSABLE,当用DML来操作该表时用到该索引,会引发ORA-01502 error,因此索引必须drop或者rebuild。
该表的统计信息也会失效,所以需要重新对该表进行统计分析,即analyze table *** compute statistics。)

但是针对ORA-01502,实际测试时并不存在
测试步骤:
SQL> create table test_altertablespace (col1 number) tablespace USERS;------------------------------------------------------创建测试表,表空间为USERS
Table created

SQL> create index idx_test_altertablespace on test_altertablespace(col1);----------------------------------------------------创建索引
Index created

SQL> select tablespace_name,status from user_indexes where index_name = 'IDX_TEST_ALTERTABLESPACE';--确认索引的状态为VALID
TABLESPACE_NAME                STATUS
------------------------------ --------
IN_MYTEST_DATA                     VALID

SQL> alter table test_altertablespace move tablespace IN_MYTEST_DATA;--------------------------------------------------迁移表空间到IN_MYTEST_DATA
Table altered

SQL> select tablespace_name,status from user_indexes where index_name = 'IDX_TEST_ALTERTABLESPACE';--确认索引的状态为VALID
TABLESPACE_NAME                STATUS
------------------------------ --------
IN_MYTEST_DATA                     VALID

SQL> insert into test_altertablespace values(1);------------------------------------------------------------------------------------------插入数据
1 row inserted
SQL> commit;
Commit complete

SQL> select tablespace_name,status from user_indexes where index_name = 'IDX_TEST_ALTERTABLESPACE';--确认索引的状态为VALID
TABLESPACE_NAME                STATUS
------------------------------ --------
IN_MYTEST_DATA                     VALID

SQL> alter table test_altertablespace move tablespace users;----------------------------------------------------------------------移动表空间到USERS
Table altered

SQL> select tablespace_name,status from user_indexes where index_name = 'IDX_TEST_ALTERTABLESPACE';--确认索引的状态为UNUSABLE
TABLESPACE_NAME                STATUS
------------------------------ --------
IN_MYTEST_DATA                     UNUSABLE
 



本文转自zylhsy 51CTO博客,原文链接:http://blog.51cto.com/yunlongzheng/397758,如需转载请自行联系原作者

相关文章
|
3月前
|
存储 Oracle NoSQL
Oracle 表空间、数据文件、schema的关系
Oracle 表空间、数据文件、schema的关系
43 2
|
4月前
|
SQL Oracle 关系型数据库
Oracle-index索引解读
Oracle-index索引解读
77 0
|
7月前
|
Oracle 关系型数据库 数据库
9-4 Oracle管理表空间和数据文件
9-4 Oracle管理表空间和数据文件
|
8月前
|
SQL 监控 Oracle
Oracle创建和管理表空间
Oracle创建和管理表空间
63 1
|
5天前
|
存储 Oracle 关系型数据库
oracle 数据库 迁移 mysql数据库
将 Oracle 数据库迁移到 MySQL 是一项复杂的任务,因为这两种数据库管理系统具有不同的架构、语法和功能。
16 0
|
19天前
|
存储 Oracle 关系型数据库
Oracle索引知识看这一篇就足够
Oracle索引知识看这一篇就足够
|
19天前
|
SQL Oracle 关系型数据库
Oracle 数据泵导出导入(映射表空间、Schema)
Oracle 数据泵导出导入(映射表空间、Schema)
|
25天前
|
存储 Oracle 关系型数据库
Oracle 12c的多重索引:数据的“多维导航仪”
【4月更文挑战第19天】Oracle 12c的多重索引提升数据查询效率,如同多维导航仪。在同一表上创建针对不同列的多个索引,加速检索过程。虽然过多索引会增加存储和维护成本,但合理选择和使用索引策略,结合位图、函数索引等高级特性,能优化查询,应对复杂场景。数据管理员应善用这些工具,根据需求进行索引管理,支持企业数据分析。
|
25天前
|
Oracle 关系型数据库
oracle 修改表空间文件路径方法
oracle 修改表空间文件路径方法
|
2月前
|
Oracle 关系型数据库 数据库
Oracle系列之五:Oracle表空间
Oracle系列之五:Oracle表空间

推荐镜像

更多