Database Reference
In-Depth Information
EODA@ORA12CR1> insert into orders values (1, to_date( '01-jun-2014', 'dd-mon-yyyy' ), 'xyz');
1 row created.
EODA@ORA12CR1> insert into orders values (2, to_date( '01-jun-2015', 'dd-mon-yyyy' ), 'xyz');
1 row created.
EODA@ORA12CR1> create table order_line_items
2 (order# number,
3 line# number,
4 data varchar2(30),
5 constraint c1_pk primary key(order#,line#),
6 constraint c1_fk_p foreign key(order#) references orders
7 ) partition by reference(c1_fk_p);
Table created.
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.
Next, an empty partition is added to the reference partitioned table:
EODA@ORA12CR1> alter table orders add partition part_2016
2 values less than (to_date('01-01-2017','dd-mm-yyyy'));
Table altered.
Next, a parent and child table are created and loaded with data. These are the tables that will be exchanged with
the empty partitions in the reference partitioned table:
EODA@ORA12CR1> create table part_2016
2 ( order# number primary key,
3 order_date date,
4 data varchar2(30));
Table created.
EODA@ORA12CR1> insert into part_2016 values (3, to_date('01-jun-2016', 'dd-mon-yyyy' ), 'xyz');
1 row created.
EODA@ORA12CR1> create table c_2016
2 (order# number,
3 line# number,
4 data varchar2(30),
5 constraint ce1_pk primary key(order#,line#),
6 constraint ce1_fk_p foreign key(order#) references part_2016);
Table created.
EODA@ORA12CR1> insert into c_2016 values(3, 1, 'xyz');
1 row created.
Search WWH ::




Custom Search