Experiment: Status of shrink and index after move in Oracle

Source: Internet
Author: User

1 move Experiment

SQL> Create Table my_objects_move tablespace assm as select * From all_objects where rownum <20000;

Table created

SQL> Create index I _my_objects_move on my_objects_move (object_id );

Index created

 

SQL> Delete from my_objects_move where object_name like '% C % ';

7546 rows deleted

SQL> Delete from my_objects_move where object_name like '% u % ';

2959 rows deleted

SQL> commit;

Commit complete

 

SQL> ALTER TABLE my_objects_move move;

Table altered

SQL> select index_name, status

2 from user_indexes

3 where index_name = 'I _ my_objects_move ';

Index_name status

--------------------------------------

I _my_objects_move
Unusable

SQL> alter index I _my_objects_move rebuild;

Index altered

 

SQL> select index_name, status

2 from user_indexes

3 where index_name = 'I _ my_objects_move ';

Index_name status

--------------------------------------

I _my_objects_move
Valid

2 shrink lab

SQL> Create Table my_objects tablespace assm as select * From all_objects where rownum <20000;

Table created

SQL> Create index I _my_objects on my_objects (object_id );

Index created

 

SQL> Delete from my_objects where object_name like '% C % ';

7546 rows deleted

SQL> Delete from my_objects where object_name like '% u % ';

2959 rows deleted

SQL> commit;

Commit complete

 

SQL> ALTER TABLE my_objects enable row movement;

Table altered

SQL> ALTER TABLE my_objects shrink space;

Table altered

 

SQL> select index_name, status

2 from user_indexes

3 where index_name = 'I _ my_objects ';

Index_name status

--------------------------------------

I _my_objects
Valid

3 conclusion

When moving row data, shrink also maintains the rowid information of the corresponding row on the index. Of course, the cost of maintaining the index in the shrink process is also high. After the table is moved, the index status is unusable and requires rebuild.

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.