问题描述:创建分区表在交换分区时报警ORA-14097的处理记录.标签:orcl150,HR,partition,NUMBER,14097,分区表,emp,table,ORA From: https://blog.51cto.com/u_12991611/6017845
数据库:oracle 11.2.0.4
1、问题重现
HR@orcl150> create table p_emp
2 (sal number(7,2))
3 partition by range(sal)
4 (partition emp_p1 values less than (10000),
5 partition emp_p2 values less than (25000));
Table created.
HR@orcl150> create table exchtab1 as select salary from employees where salary<10000;
Table created.
HR@orcl150> create table exchtab2 as select salary from employees where salary between 10000 and 25000;
Table created.
HR@orcl150> alter table p_emp exchange partition emp_p1 with table exchtab1;
alter table p_emp exchange partition emp_p1 with table exchtab1
*
ERROR at line 1:
ORA-14097: column type or size mismatch in ALTER TABLE EXCHANGE PARTITION
2、解决方案
说明:根据告警提示,查字段类型,发现salary字段类型为NUMBER(8,2).
HR@orcl150> set line 100
HR@orcl150> desc employees
Name Null? Type
----------------------------------------------------- -------- ------------------------------------
EMPLOYEE_ID NOT NULL NUMBER(6)
FIRST_NAME VARCHAR2(20)
LAST_NAME NOT NULL VARCHAR2(25)
EMAIL NOT NULL VARCHAR2(25)
PHONE_NUMBER VARCHAR2(20)
HIRE_DATE NOT NULL DATE
JOB_ID NOT NULL VARCHAR2(10)
SALARY NUMBER(8,2)
COMMISSION_PCT NUMBER(2,2)
MANAGER_ID NUMBER(6)
DEPARTMENT_ID NUMBER(4)
HR@orcl150> desc exchtab1
Name Null? Type
----------------------------------------------------- -------- ------------------------------------
SALARY NUMBER(8,2)
HR@orcl150> drop table p_emp purge;
Table dropped.
--修改表p_emp的salary字段类型.
HR@orcl150> create table p_emp
2 (sal number(8,2))
3 partition by range(sal)
4 (partition emp_p1 values less than (10000),
5 partition emp_p2 values less than (25000));
Table created.
--此后成功交换分区
HR@orcl150> alter table p_emp exchange partition emp_p1 with table exchtab1;
Table altered.