Beruflich Dokumente
Kultur Dokumente
empno
NUMBER(4) NOT NULL CONSTRAINT emp_pk PRIMARY KEY,
ename
VARCHAR2(10),
job
VARCHAR2(9),
mgr
NUMBER(4),
hiredate
DATE,
sal
NUMBER(7,2) CONSTRAINT emp_sal_ck CHECK (sal > 0),
comm
NUMBER(7,2),
deptno
NUMBER(2)
)
PARTITION BY RANGE (deptno)
(PARTITION employees_part1 VALUES LESS THAN (11) ,
PARTITION employees_part2 VALUES LESS THAN (21) ,
PARTITION employees_part3 VALUES LESS THAN (31) );
update emp set deptno=20 where deptno=30;
update emp partition(employees_part3) set deptno=20; will cause the following er
ror:
ORA-14402: updating partition key column would cause a partition change
An UPDATE statement attempted to change the value of a partition
key column causing migration of the row to another partition
Solution:
alter table emp ENABLE ROW MOVEMENT;
to compress the table rows into less data blocks, and Oracle moves down the high
water mark to release the space. This makes full-table scans run faster. Flashb
ack table - Using the flashback table features requires "enable row movement".
To Update a partiton key value and to flashback the data.
Now update will works fine and data will be noved to other partiton:
Move = Delete from current + Insert into other
update emp set deptno=21 where deptno=30; This works fine and changes the rowid.
later operation will move the data into corrosponding partiitons.
Note: you're not just updating a single column and leaving the row in place, you
're actually moving the row to a new block. You're also requiring that two parti
tions of every local index be modified .
if any partition is used we can see it in PLAN_TABLE under operation/options col
umns or PARTITION_START/PARTITION _STOP Columns.
Partition pruning is an essential performance feature for data warehouses. In pa
rtition pruning, the optimizer analyzes FROM and WHERE clauses in SQL statements
to eliminate unneeded partitions when building the partition access list. This
functionality enables Oracle Database to perform operations only on those partit
ions that are relevant to the SQL statement.
Partition pruning dramatically reduces the amount of data retrieved from disk an
d shortens processing time, thus improving query performance and optimizing reso
urce utilization.
For many cases, Oracle determines the partitions to be accessed at compile time.
Static partition pruning occurs if you use static predicates, except for the fo
llowing cases:
Partition pruning occurs using the result of a subquery.
The optimizer rewrites the query with a star transformation and pruning occurs af
ter the star transformation.
The most efficient execution plan is a nested loop.
The Query uses bind variables.