1 创建分区表emp2
sql
CREATE TABLE emp2
(empno NUMBER(4) NOT NULL,
ename VARCHAR2(10),
sal NUMBER(7))
PARTITION BY RANGE(ename)
(partition emp2_p1 VALUES LESS THAN ('D'),
partition emp2_p2 VALUES LESS THAN ('Q'),
partition emp2_p3 VALUES LESS THAN (MAXVALUE)
);
2 创建普通表emp_tmp
sql
create table emp_tmp
(
empno NUMBER(4) NOT NULL,
ename VARCHAR2(10),
sal NUMBER(7)
);
3 往表中插入数据
sql
insert into emp2 values(1,'Andy',575);
insert into emp2 values(2,'Derek',570);
insert into emp2 values(3,'Patrick',590);
insert into emp2 values(4,'Richard',400);
insert into emp_tmp values(5,'Heidi',666);
4 将emp2的emp2_p2分区和普通表emp_tmp进行交换
sql
alter table emp2 exchange partition emp2_p2 with table emp_tmp;