oracle分割槽表和非分割槽表exchange

a960549548發表於2024-03-15

1 建立分割槽表 emp2

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

create table emp_tmp
  (
  empno NUMBER(4) NOT NULL,
  ename VARCHAR2(10),
  sal NUMBER(7)
   );

3 往表中插入資料

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 進行交換

alter table emp2 exchange partition emp2_p2 with table emp_tmp;


來自 “ ITPUB部落格 ” ,連結:https://blog.itpub.net/70013625/viewspace-3009043/,如需轉載,請註明出處,否則將追究法律責任。

相關文章