日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發布時間:2025/5/22 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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
?

轉載于:https://blog.51cto.com/yunlongzheng/397758

總結

以上是生活随笔為你收集整理的oracle 10G 表空间迁移 索引需要重建的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。