Hi Parag
Code:
CREATE TABLE table2000
( x int,
y int,
z DATE
)
PARTITION BY RANGE (z)
(
PARTITION tab_1999_h1 VALUES LESS
THAN(to_date('30-jun-1999','dd-mon-yyyy')),
PARTITION tab_1999_h2 VALUES LESS
THAN(to_date('31-dec-1999','dd-mon-yyyy')),
PARTITION tab_2000_h1 VALUES LESS
THAN(to_date('30-jun-2000','dd-mon-yyyy')),
PARTITION tab_2000_h2 VALUES LESS
THAN(to_date('31-dec-2000','dd-mon-yyyy'))
)
/
Table created.
insert into table2000 values ( 1, 1, '15-jun-1999' );
insert into table2000 values ( 2, 2, '15-dec-1999' );
insert into table2000 values ( 3, 3, '15-jun-2000' );
insert into table2000 values ( 4, 4, '15-dec-2000' );
CREATE TABLE new_table2000
( x int,
y int,
z DATE
)
PARTITION BY RANGE (z)
(
PARTITION newtab_1999_h1 VALUES LESS
THAN(to_date('30-jun-1999','dd-mon-yyyy')),
PARTITION newtab_1999_h2 VALUES LESS
THAN(to_date('31-dec-1999','dd-mon-yyyy'))
)
/
Table created.
insert into NEW_table2000 values ( -1, -1, '15-jun-1999' );
insert into NEW_table2000 values ( -2, -2, '15-dec-1999' );
create table temp ( x int, y int, z date );
Table created.
alter table new_table2000
exchange partition newtab_1999_h1
with table temp;
Table altered.
alter table table2000
exchange partition tab_1999_h1
with table temp;
Table altered.
rename temp to table2000_tab_1999_h1;
Table renamed.
select * from table2000;
X Y Z
---------- ---------- ---------
-1 -1 15-JUN-99
2 2 15-DEC-99
3 3 15-JUN-00
4 4 15-DEC-00
so the old data is actually overwritten not appended.
regards
Hrishy
Bookmarks