Thursday, February 12, 2009

Moving User Indexes and User Tables to new tablespace

It is the need for good performance to maintain separate tablespace for user indexes. One can assign the tablespace name to the user index tablespace at the time index creation or can move the index to a new tablespace afterwards.

At the time of table creation
CREATE INDEX index_name ON table_name (col1, col2) TABLESPACE tablespace_name;
The index will be created in users default tablespace if the tablespace option is ommitted.

To move index to other index tablespace
ALTER INDEX index_name REBUILD TABLESPACE indx_tablespace_name;
This move the index to name tablespace and rebuild the index.

To move table to new tablespace
ALTER TABLE table_name MOVE TABLESPACE tablespace_name;
This will move table to new tablespace.

No comments: