ORA-39257: Data cannot be remapped for more than 10 columns.

前言

还是脱敏数据相关的事情。

使用expdp的remap_data参数对指定列进行一定规则转换后,如果指定转换的列超过10列,则报错ORA-39257。

ORA-39001: invalid argument value
ORA-39257: Data cannot be remapped for more than 10 columns.

注意:这是一个BUG,可以用补丁修复。

环境模拟

自己的环境模拟吧。

数据库版本:

SYS@zkm> select * from v$version where rownum=1;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production SYS@zkm>

构造表(20个字段,超过10个即可)。

create table scott.test (id number);

begin
for i in 1..19 loop
execute immediate 'alter table scott.test add a'||i||' number(1)';
end loop;
end;
/

模板复制

SYS@zkm> create table scott.test (id number);

Table created.

SYS@zkm> begin
2 for i in 1..19 loop
3 execute immediate 'alter table scott.test add a'||i||' number(1)';
4 end loop;
5 end;
6 / PL/SQL procedure successfully completed. SYS@zkm> desc scott.test
Name Null? Type
----------------------------------------- -------- ----------------------------
ID NUMBER
A1 NUMBER(1)
A2 NUMBER(1)
A3 NUMBER(1)
A4 NUMBER(1)
A5 NUMBER(1)
A6 NUMBER(1)
A7 NUMBER(1)
A8 NUMBER(1)
A9 NUMBER(1)
A10 NUMBER(1)
A11 NUMBER(1)
A12 NUMBER(1)
A13 NUMBER(1)
A14 NUMBER(1)
A15 NUMBER(1)
A16 NUMBER(1)
A17 NUMBER(1)
A18 NUMBER(1)
A19 NUMBER(1)

创建包和包体,包中定制数据转换规则,不需要太复杂。

create or replace package scott.pkg_remap
is
function fn_numeral_1(input_string number) return number;
end;
/ create or replace package body scott.pkg_remap
is
function fn_numeral_1(input_string number) return number as
begin
return input_string+1;
end;
end;
/

模板复制

SYS@zkm> create or replace package scott.pkg_remap
2 is
3 function fn_numeral_1(input_string number) return number;
4 end;
5 / Package created. SYS@zkm> create or replace package body scott.pkg_remap
2 is
3 function fn_numeral_1(input_string number) return number as
4 begin
5 return input_string+1;
6 end;
7 end;
8 / Package body created.

不需要有数据,直接导出就报错了。

create directory dirtmp as '/home/oracle/';

expdp \' / as sysdba\' directory=dirtmp dumpfile=test.dmp logfile=test.log cluster=n tables=scott.test reuse_dumpfiles=y remap_data=scott.test.a1:scott.pkg_remap.fn_numeral_1,scott.test.a2:scott.pkg_remap.fn_numeral_1,scott.test.a3:scott.pkg_remap.fn_numeral_1,scott.test.a4:scott.pkg_remap.fn_numeral_1,scott.test.a5:scott.pkg_remap.fn_numeral_1,scott.test.a6:scott.pkg_remap.fn_numeral_1,scott.test.a7:scott.pkg_remap.fn_numeral_1,scott.test.a8:scott.pkg_remap.fn_numeral_1,scott.test.a9:scott.pkg_remap.fn_numeral_1,scott.test.a10:scott.pkg_remap.fn_numeral_1,scott.test.a11:scott.pkg_remap.fn_numeral_1

模板复制

SYS@zkm> create directory dirtmp as '/home/oracle/';

Directory created.

[oracle@oracle ~]$ expdp \' / as sysdba\' directory=dirtmp dumpfile=test.dmp logfile=test.log cluster=n tables=scott.test reuse_dumpfiles=y remap_data=scott.test.a1:scott.pkg_remap.fn_numeral_1,scott.test.a2:scott.pkg_remap.fn_numeral_1,scott.test.a3:scott.pkg_remap.fn_numeral_1,scott.test.a4:scott.pkg_remap.fn_numeral_1,scott.test.a5:scott.pkg_remap.fn_numeral_1,scott.test.a6:scott.pkg_remap.fn_numeral_1,scott.test.a7:scott.pkg_remap.fn_numeral_1,scott.test.a8:scott.pkg_remap.fn_numeral_1,scott.test.a9:scott.pkg_remap.fn_numeral_1,scott.test.a10:scott.pkg_remap.fn_numeral_1,scott.test.a11:scott.pkg_remap.fn_numeral_1

Export: Release 11.2.0.4.0 - Production on Wed May 13 14:56:27 2020

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-39001: invalid argument value
ORA-39257: Data cannot be remapped for more than 10 columns.

mos上可以搜索到,这个一个BUG。

Bug 14202396 - Datapump remap_data fails if used for more than 10 cols in a table (Doc ID 14202396.8)

下载并打补丁。

解压。

[oracle@oracle ~]$ unzip p14202396_112040_Generic.zip
Archive: p14202396_112040_Generic.zip
creating: /
inflating: /README.txt
creating: /etc/
creating: /etc/xml/
inflating: /etc/xml/ShiphomeDirectoryStructure.xml
inflating: /etc/xml/GenericActions.xml
creating: /etc/config/
inflating: /etc/config/actions.xml
inflating: /etc/config/inventory.xml
inflating: /etc/config/deploy.xml
creating: /files/
creating: /files/sqlpatch/
creating: /files/sqlpatch//
inflating: /files/sqlpatch//postdeinstall.sql
inflating: /files/sqlpatch//postinstall.sql
creating: /files/rdbms/
creating: /files/rdbms/admin/
inflating: /files/rdbms/admin/prvtbpm.plb
inflating: /files/rdbms/admin/prvtbpd.plb
inflating: /files/rdbms/admin/prvtkupc.plb
inflating: /files/rdbms/admin/catmeta.sql
creating: /files/rdbms/xml/
creating: /files/rdbms/xml/xsl/
inflating: /files/rdbms/xml/xsl/kuemodtb.xsl
inflating: /files/rdbms/xml/xsl/kuetable.xsl
inflating: /files/rdbms/xml/xsl/kumodtab.xsl
inflating: /files/rdbms/xml/xsl/kucolumn.xsl
inflating: /postinstall.sql
replace PatchSearch.xml? [y]es, [n]o, [A]ll, [N]one, [r]ename: A
inflating: PatchSearch.xml

这不是一个Rolling Patch,

[oracle@oracle ]$ opatch query . |grep rolling
Patch is a rolling patch: false
Patch is a FMW rolling patch: false

但是可以不需要停止数据库和监听等服务,在补丁目录下的etc/config/inventory.xml文件中有这个字样,

<oneoff_inventory>
<opack_version version="11.1.0.4.0"/>
<reference_id number=""/>
<unique_patch_id></unique_patch_id>
<date_of_patch year="" month="Apr" day="" time="11:51:05 hrs" zone="PST8PDT"/>
<base_bugs>
<bug number="" description="REMAP_DATA FAILS IF USED FOR MORE THAN 10 COLS IN A TABLE"/>
</base_bugs>
<required_components>
<component internal_name="oracle.rdbms" version="11.2.0.4.0" opt_req="O"/>
<component internal_name="oracle.rdbms.dbscripts" version="11.2.0.4.0" opt_req="O"/>
</required_components>
<os_platforms>
<platform name="Generic Platform 1" id=""/>
</os_platforms>
<executables></executables>
<instance_shutdown>false</instance_shutdown>
<instance_shutdown_message></instance_shutdown_message>
<online_rac_installable>false</online_rac_installable>
<run_as_root>false</run_as_root>
<sql_migrate>false</sql_migrate>
<wls_prereq_oneoffs></wls_prereq_oneoffs>
<prereq_oneoffs></prereq_oneoffs>
<coreq_oneoffs></coreq_oneoffs>
<overlay_oneoffs></overlay_oneoffs>
<patch_type value="singleton"/>
<product_family value="db"/>
<auto>false</auto>
<applicable_product value=""/>
<products></products>
<update_components></update_components>
</oneoff_inventory>

而且,readme中也没有步骤说明需要停服务。

在以往认知中小补丁除了online patch是可以不需要停机打的,这里按照readme来也不需要,还有需不需要考虑RAC的问题,有点虚。

当然,PSU是肯定要停集群停数据库的。

关于<instance_shutdown>false</instance_shutdown>这一项,网上有点少谈到这个,有时间我研究下。

打补丁(OPatch我的环境是升级过的,不需要考虑OPatch版本的问题了)。

[oracle@oracle ]$ pwd
/home/oracle/
[oracle@oracle ]$ opatch apply
Oracle Interim Patch Installer version 11.2.0.3.
Copyright (c) , Oracle Corporation. All rights reserved. Oracle Home : /u01/app/oracle/product/11.2./db_1
Central Inventory : /u01/app/oraInventory
from : /u01/app/oracle/product/11.2./db_1/oraInst.loc
OPatch version : 11.2.0.3.
OUI version : 11.2.0.4.
Log file location : /u01/app/oracle/product/11.2./db_1/cfgtoollogs/opatch/opatch2020--13_15--51PM_1.log Verifying environment and performing prerequisite checks...
OPatch continues with these patches: Do you want to proceed? [y|n]
y
User Responded with: Y
All checks passed.
Provide your email address to be informed of security issues, install and
initiate Oracle Configuration Manager. Easier for you if you use your My
Oracle Support Email address/User Name.
Visit http://www.oracle.com/support/policies.html for details.
Email address/User Name: You have not provided an email address for notification of security issues.
Do you wish to remain uninformed of security issues ([Y]es, [N]o) [N]: Y Backing up files...
Applying interim patch '' to OH '/u01/app/oracle/product/11.2.0/db_1' Patching component oracle.rdbms, 11.2.0.4.... Patching component oracle.rdbms.dbscripts, 11.2.0.4....
Patch successfully applied.
Log file location: /u01/app/oracle/product/11.2./db_1/cfgtoollogs/opatch/opatch2020--13_15--51PM_1.log OPatch succeeded.

跑脚本。
sqlplus / as sysdba
@?/sqlpatch//postinstall.sql
...这一步输出略,太多了...

再次导出数据,已经不再报错了。

[oracle@oracle ]$ expdp \' / as sysdba\' directory=dirtmp dumpfile=test.dmp logfile=test.log cluster=n tables=scott.test reuse_dumpfiles=y remap_data=scott.test.a1:scott.pkg_remap.fn_numeral_1,scott.test.a2:scott.pkg_remap.fn_numeral_1,scott.test.a3:scott.pkg_remap.fn_numeral_1,scott.test.a4:scott.pkg_remap.fn_numeral_1,scott.test.a5:scott.pkg_remap.fn_numeral_1,scott.test.a6:scott.pkg_remap.fn_numeral_1,scott.test.a7:scott.pkg_remap.fn_numeral_1,scott.test.a8:scott.pkg_remap.fn_numeral_1,scott.test.a9:scott.pkg_remap.fn_numeral_1,scott.test.a10:scott.pkg_remap.fn_numeral_1,scott.test.a11:scott.pkg_remap.fn_numeral_1

Export: Release 11.2.0.4. - Production on Wed May  :: 

Copyright (c) , , Oracle and/or its affiliates.  All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4. - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYS"."SYS_EXPORT_TABLE_01": "/******** AS SYSDBA" directory=dirtmp dumpfile=test.dmp logfile=test.log cluster=n tables=scott.test reuse_dumpfiles=y remap_data=scott.test.a1:scott.pkg_remap.fn_numeral_1,scott.test.a2:scott.pkg_remap.fn_numeral_1,scott.test.a3:scott.pkg_remap.fn_numeral_1,scott.test.a4:scott.pkg_remap.fn_numeral_1,scott.test.a5:scott.pkg_remap.fn_numeral_1,scott.test.a6:scott.pkg_remap.fn_numeral_1,scott.test.a7:scott.pkg_remap.fn_numeral_1,scott.test.a8:scott.pkg_remap.fn_numeral_1,scott.test.a9:scott.pkg_remap.fn_numeral_1,scott.test.a10:scott.pkg_remap.fn_numeral_1,scott.test.a11:scott.pkg_remap.fn_numeral_1
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: KB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "SCOTT"."TEST" KB rows
Master table "SYS"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYS.SYS_EXPORT_TABLE_01 is:
/home/oracle/test.dmp
Job "SYS"."SYS_EXPORT_TABLE_01" successfully completed at Wed May :: elapsed ::

PS:我虚拟机的时间是有问题的(手动狗头)。

后续

由于是生产的RAC环境,最后还是没有打。

搞成dblink导出到(顺便转换)别的库后,直接expdp。

ORA-39257: Data cannot be remapped for more than 10 columns.的更多相关文章

  1. C and SQL data types for ODBC and CLI

    C and SQL data types for ODBC and CLI   This topic lists the C and SQL data types for ODBC and CLI a ...

  2. 【DATAGUARD】物理dg配置客户端无缝切换 (八.1)--Data Guard Broker 的配置

    [DATAGUARD]物理dg配置客户端无缝切换 (八.1)--Data Guard Broker 的配置 一.1  BLOG文档结构图       一.2  前言部分   一.2.1  导读 各位技 ...

  3. 关于动态生成data组件

    /*! * WeX5 v3 (http://www.justep.com) * Copyright 2015 Justep, Inc. * Licensed under Apache License, ...

  4. 转:主流数据恢复软件——EasyRecovery/Ashampoo Undeleter/Wise Data Recovery/Recuva/Undelete 360

    转自:Baidu 空间 2012-10-05 13:57 主流数据恢复软件——EasyRecovery/Ashampoo Undeleter/Wise Data Recovery/Recuva/Und ...

  5. MySQL vs. MongoDB: Choosing a Data Management Solution

    原文地址:http://www.javacodegeeks.com/2015/07/mysql-vs-mongodb.html 1. Introduction It would be fair to ...

  6. How much training data do you need?

    How much training data do you need?   //@樵夫上校: 0. 经验上,10X规则(训练数据是模型参数量的10倍)适用与大多数模型,包括shallow networ ...

  7. Tutorial: Analyzing sales data from Excel and an OData feed

    With Power BI Desktop, you can connect to all sorts of different data sources, then combine and shap ...

  8. Part 9 Sorting data in AngularJS

    To sort the data in Angular 1. Use orderBy filter     {{ orderBy_expression | orderBy : expression : ...

  9. Spring mvc Data Redis—Pub/Sub(附Web项目源码)

    一.发布和订阅机制 当一个客户端通过 PUBLISH 命令向订阅者发送信息的时候,我们称这个客户端为发布者(publisher). 而当一个客户端使用 SUBSCRIBE 或者 PSUBSCRIBE ...

随机推荐

  1. Java实现 LeetCode 232 用栈实现队列

    232. 用栈实现队列 使用栈实现队列的下列操作: push(x) – 将一个元素放入队列的尾部. pop() – 从队列首部移除元素. peek() – 返回队列首部的元素. empty() – 返 ...

  2. SQLServer2019安装教程

    可以去官网下载,我百度网盘也有都一样 https://pan.baidu.com/s/1i3umqHXSUMbxJ9rRi6mU4A 提取码:5g9q 打开应用程序 点击安装,点第一个全新得SQL s ...

  3. Java实现 洛谷 P1055 ISBN号码

    import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public ...

  4. Java实现 蓝桥杯 历届试题 连号区间数

    问题描述 小明这些天一直在思考这样一个奇怪而有趣的问题: 在1~N的某个全排列中有多少个连号区间呢?这里所说的连号区间的定义是: 如果区间[L, R] 里的所有元素(即此排列的第L个到第R个元素)递增 ...

  5. java实现第八届蓝桥杯生命游戏

    生命游戏 题目描述 康威生命游戏是英国数学家约翰·何顿·康威在1970年发明的细胞自动机. 这个游戏在一个无限大的2D网格上进行. 初始时,每个小方格中居住着一个活着或死了的细胞. 下一时刻每个细胞的 ...

  6. java实现第四届蓝桥杯错误票据

    错误票据 题目描述 某涉密单位下发了某种票据,并要在年终全部收回. 每张票据有唯一的ID号.全年所有票据的ID号是连续的,但ID的开始数码是随机选定的. 因为工作人员疏忽,在录入ID号的时候发生了一处 ...

  7. 从程序员到项目主管再到项目总监,一个IT从业者三个职业生涯阶段的工作生活日常

    这是王不留的第 8 篇原创文章 前段时间写过<王不留的十多年工作和生活的流水帐>,在知乎.简书,还有不少微信的朋友私信问我每天四点钟是如何做到的?你现在的作息时间是怎么安排的? 于是,我将 ...

  8. spring-framework 源码的下载与构建

    整体流程: 本地环境准备 找到源码地址并拉取到本地 根据IDE工具查看源码中提供的不同的安装说明并具体操作 构建会出现的的错误及解决 一.本地环境准备 spring-framework 源码使用gra ...

  9. JSP和Servlet的相同点和不同点、有何联系。

    JSP 和 Servlet 有哪些相同点和不同点,他们之间的联系是什么? 联系: JSP 是 Servlet 技术的扩展,本质上是 Servlet 的简易方式,更强调应用的外表表达. JSP编译后是& ...

  10. 基于 abp vNext 和 .NET Core 开发博客项目 - Blazor 实战系列(五)

    系列文章 基于 abp vNext 和 .NET Core 开发博客项目 - 使用 abp cli 搭建项目 基于 abp vNext 和 .NET Core 开发博客项目 - 给项目瘦身,让它跑起来 ...