05.11.2015 Views

Apress.Expert.Oracle.Database.Architecture.9i.and.10g.Programming.Techniques.and.Solutions.Sep.2005

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

580<br />

CHAPTER 13 ■ PARTITIONING<br />

We take one of the rows <strong>and</strong> update the value in its RANGE_KEY_COLUMN such that it can<br />

remain in PART_1:<br />

ops$tkyte@ORA10G> update range_example<br />

2 set range_key_column = trunc(range_key_column)<br />

3 where range_key_column =<br />

4 to_date( '31-dec-2004 23:59:59',<br />

5 'dd-mon-yyyy hh24:mi:ss' );<br />

1 row updated.<br />

As expected, this succeeds: the row remains in partition PART_1. Next, we update the<br />

RANGE_KEY_COLUMN to a value that would cause it to belong in PART_2:<br />

ops$tkyte@ORA10G> update range_example<br />

2 set range_key_column = to_date('02-jan-2005','dd-mon-yyyy')<br />

3 where range_key_column = to_date('31-dec-2004','dd-mon-yyyy');<br />

update range_example<br />

*<br />

ERROR at line 1:<br />

ORA-14402: updating partition key column would cause a partition change<br />

That immediately raises an error, since we did not explicitly enable row movement. In<br />

<strong>Oracle</strong>8i <strong>and</strong> later releases, we can enable row movement on this table to allow the row to<br />

move from partition to partition.<br />

■Note The row movement functionality is not available on <strong>Oracle</strong> 8.0; you must delete the row <strong>and</strong> reinsert<br />

it in that release.<br />

You should be aware of a subtle side effect of doing this, however; namely that the ROWID<br />

of a row will change as the result of the update:<br />

ops$tkyte@ORA10G> select rowid<br />

2 from range_example<br />

3 where range_key_column = to_date('31-dec-2004','dd-mon-yyyy');<br />

ROWID<br />

------------------<br />

AAARmfAAKAAAI+aAAB<br />

ops$tkyte@ORA10G> alter table range_example<br />

2 enable row movement;<br />

Table altered.<br />

ops$tkyte@ORA10G> update range_example<br />

2 set range_key_column = to_date('02-jan-2005','dd-mon-yyyy')<br />

3 where range_key_column = to_date('31-dec-2004','dd-mon-yyyy');<br />

1 row updated.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!