Database Reference
In-Depth Information
EODA@ORA12CR1> insert into order_line_items values ( 1, 1, 'yyy' );
1 row created.
EODA@ORA12CR1> insert into order_line_items values ( 2, 1, 'yyy' );
1 row created.
Now we can issue a TRUNCATE ... CASCADE that truncates both the parent table partition and the child table
partition as a single transaction:
EODA@ORA12CR1> alter table orders truncate partition PART_2014 cascade;
Table truncated.
In other words, the TRUNCATE ... CASCADE functionality prevents applications from seeing the child table
truncated before the parent table is truncated.
You can also truncate all partitions in the parent and child tables via:
EODA@ORA12CR1> truncate table orders cascade;
Table truncated.
Again, just to be clear, the ability to cascade truncate parent/child tables is not exclusively a partitioning feature.
This feature also applies to nonpartitioned parent/child tables. This allows you to use one DDL statement to initiate
truncate operations and also ensures the database application is always presented with a consistent view of parent/
child partitions.
Cascade Exchange
Prior to Oracle 12 c , when exchanging partitions for a reference partitioned table, the sequence was roughly this:
1.
Create and load parent table.
2.
Create parent partition in reference partitioned table.
3.
Exchange parent table specifying UPDATE GLOBAL INDEXES .
4.
Create child table with a foreign key constraint that points at the reference partitioned parent.
5.
Load child table.
6.
Exchange child table with child reference partition.
As you can see from the prior steps, there exists the potential for users accessing the database to see data in
the parent table without the corresponding rows in the child table. Prior to Oracle 12 c there was no way around this
behavior.
Starting with Oracle 12 c you can exchange the combination of parent/child reference partitioned tables in one
atomic DDL statement. A small example will demonstrate this. First, a reference partitioned parent and child table is
created to set this up:
EODA@ORA12CR1> create table orders
2 ( order# number primary key,
3 order_date date,
4 data varchar2(30))
5 PARTITION BY RANGE (order_date)
6 (PARTITION part_2014 VALUES LESS THAN (to_date('01-01-2015','dd-mm-yyyy')) ,
7 PARTITION part_2015 VALUES LESS THAN (to_date('01-01-2016','dd-mm-yyyy')));
Table created.
 
Search WWH ::




Custom Search