Row movement in oracle

Row movement is associated with partitioned and non-partitioned tables but is mostly associated with non-partitione tables. For partitioned tables when ROW MOVEMENT is enabled users have the ability to update partitioning key columns in such a way that a row no longer belongs in its current partition, causing such rows to migrate to the appropriate partition. Row movement is enabled at the table level and is disabled by default.

For example:

CREATE TABLE sales(
sale_id NUMBER NOT NULL,
sale_date DATE,
prod_id NUMBER,
qty NUMBER)
PARTITION BY RANGE(prod_id)
(PARTITION salesp1 VALUES LESS THAN(10),
PARTITION salesp2 VALUES LESS THAN(20),
PARTITION salesp3 VALUES LESS THAN(30),
PARTITION salesp4 VALUES LESS THAN(40))

Partition salesp1 above will have prod_id values upto 9 (since partition high values are non-inclusive). If you issue an update statement like this:

SQL> update sales set prod_id = 15 where prod_id = 5;

For the above statement to succeed, oracle has to migrate the row that you are updating from partition salesp1 to salesp2. Under those circumstances, it will raise this error:
ORA-14402: updating partition key column would cause a partition change

You can overcome the above error by issuing this statement:

SQL> ALTER TABLE sales ENABLE ROW MOVEMENT;

-- You can now issue the update statement successfully

SQL> update sales set prod_id = 15 where prod_id = 5;
4 rows updated
SQL> commit;

Row movement is allowed for non-partitioned tables starting 9i. Row movement comes in to affect for non-partitioned tables when you do operations like table compression.
Couple of things to be beware of with row movement are
(1) Oracle will do a delete and insert in the background which can cause
performance issues and
(2) The rowid for the row that went through row migration will change which can potentially cause problems if the application uses static rowids for data access.

I don't remember which URL I got this info from.But it is really good .If someone can tell me the URL I will remove this article and post the link here

Comments

Popular posts from this blog

ORA-04062: timestamp of procedure has been changed

ORA-00939: too many arguments -when case arguments exceed 255

ORA-31655: no data or metadata objects selected for job