简体   繁体   English

Oracle-使用remap_data参数和datapump导出的错误ORA-00907

[英]Oracle - Error ORA-00907 using remap_data parameter with datapump export

I'm trying to export data with the remap_data parameter (datapump mode) in order to hide some data. 我正在尝试使用remap_data参数(数据泵模式)导出数据以隐藏一些数据。

This works fine with "varchar2" or "number" column but fail with "long" column. 在“ varchar2”或“ number”列中工作正常,但在“ long”列中失败。 In the export log file we can see the ORA-31693 error then the ORA-00907 error. 在导出日志文件中,我们可以看到ORA-31693错误,然后是ORA-00907错误。

Can anyone please help me with this ? 有人可以帮我吗? Thanks 谢谢

Here is my example code : 这是我的示例代码:

-- data creation
create table TABLE1 (
   COL1         LONG
)
tablespace TAB
/

INSERT INTO TABLE1 (COL1) VALUES ('data1');

COMMIT;

-- package creation
CREATE OR REPLACE PACKAGE hidelong AS
    FUNCTION change_long ( valuetest IN LONG ) RETURN LONG;
END hidelong;
/

CREATE OR REPLACE PACKAGE BODY hidelong AS
    LongX LONG := 'XXXXXXXXXX';

    FUNCTION change_long ( valuetest IN LONG ) RETURN LONG IS
    BEGIN
        RETURN LongX;
    END change_long;

END hidelong;
/

Export command : 导出命令:

expdp system/manager@DB1 schemas=TEST directory=datapump dumpfile=EXP.DMP LOGFILE=EXP.log remap_data=TEST.TABLE1.COL1:hidelong.change_long

EXP.log file content : EXP.log文件内容:

Export: Release 11.2.0.1.0 - Production on Mer. Avr. 20 14:56:30 2016

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
;;; 
Connecté à : Oracle Database 11g Release 11.2.0.1.0 - 64bit Production
Démarrage de "SYSTEM"."SYS_EXPORT_SCHEMA_01" : system/********@DB1 schemas=TEST directory=datapump dumpfile=EXP.DMP LOGFILE=EXP.log remap_data=TEST.TABLE1.COL1:hidelong.change_long 
Estimation en cours à l'aide de la méthode BLOCKS ...
Traitement du type d'objet SCHEMA_EXPORT/TABLE/TABLE_DATA
Estimation totale à l'aide le la méthode BLOCKS : 64 KB
Traitement du type d'objet SCHEMA_EXPORT/USER
Traitement du type d'objet SCHEMA_EXPORT/SYSTEM_GRANT
Traitement du type d'objet SCHEMA_EXPORT/ROLE_GRANT
Traitement du type d'objet SCHEMA_EXPORT/DEFAULT_ROLE
Traitement du type d'objet SCHEMA_EXPORT/TABLESPACE_QUOTA
Traitement du type d'objet SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Traitement du type d'objet SCHEMA_EXPORT/TABLE/TABLE
Traitement du type d'objet SCHEMA_EXPORT/PACKAGE/PACKAGE_SPEC
Traitement du type d'objet SCHEMA_EXPORT/PACKAGE/COMPILE_PACKAGE/PACKAGE_SPEC/ALTER_PACKAGE_SPEC
Traitement du type d'objet SCHEMA_EXPORT/PACKAGE/PACKAGE_BODY
ORA-31693: Echec du chargement/déchargement de l'objet de données de table "TEST"."TABLE1" ; l'objet est ignoré en raison de l'erreur :
ORA-00907: parenthèse de droite absente
Table maître "SYSTEM"."SYS_EXPORT_SCHEMA_01" chargée/déchargée avec succès
******************************************************************************
L'ensemble de fichiers de vidage de SYSTEM.SYS_EXPORT_SCHEMA_01 est :
  C:\EXP.DMP
Travail "SYSTEM"."SYS_EXPORT_SCHEMA_01" terminé avec 1 erreur(s) à 14:57:03

The documentation doesn't mention a restriction on using REMAP_DATA with LONG columns, but as they are restricted in other ways - including not being able to call a function that takes a LONG parameter from SQL, which gets ORA-00997 - it's not entirely surprising it isn't allowed. 该文档没有提及将REMAP_DATA与LONG列一起使用的限制,但是由于它们以其他方式受到限制-包括无法从SQL调用带有LONG参数的函数,从而获得ORA-00997-这并不完全令人惊讶这是不允许的。

There is an Oracle white paper on "Data Transformations with Oracle Data Pump" , which includes a section on page 6 on "Special Considerations When Using REMAP_DATA": 有一份有关“使用Oracle Data Pump进行数据转换”的Oracle白皮书,其中包括第6页的“使用REMAP_DATA时的特殊注意事项”一节:

There are other restrictions for the REMAP_DATA parameter that cannot be worked around. REMAP_DATA参数还有其他限制,无法解决。 ... It also cannot be used for modifying tables that contain columns with the LONG or LONG RAW datatypes. ...也不能用于修改包含具有LONG或LONG RAW数据类型的列的表。

The message you're getting is unhelpful, and there's a bug (19157986) about the ORA-00907 being misleading. 您收到的消息没有帮助,并且存在一个错误(19157986)关于ORA-00907产生了误导。 Short of converting your LONG column to a CLOB, there doesn't seem to be a workaround 缺少将LONG列转换为CLOB的方法,似乎没有解决方法

Anecdotally it may affect other datatypes as well . 有趣的是, 它也可能影响其他数据类型

As there is no workaround I have to export a different way, for example : 由于没有解决方法,因此我必须以其他方式导出,例如:

  • I will export entire database and exclude TABLE1 我将导出整个数据库并排除TABLE1

  • I will create a dump of TABLE1 with : 我将使用创建一个TABLE1的转储:

create table TABLE1_ext
  organization external (
    type oracle_datapump
    default directory datapump
    location ('TABLE1.dmp')
  )
as select 'XXXXXXXXXX' as COL1 from TEST.TABLE1;

Then I will import these 2 dump files generated. 然后,我将导入生成的这2个转储文件。

It would be OK by this way. 这样就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM