首页 文章

Oracle转储文件表数据提取到文件(原始exp格式)

提问于
浏览
2

我有使用原始exp(不是expdp)创建的Oracle转储文件(EXPORT:V10.02.01,Oracle 10g) . 它们仅包含四个表的表数据 .

1)我想将表数据提取到文件(平面/固定宽度,CVS或其他文本文件)中,而不将它们导入另一个Oracle DB . [优选的]

2)或者,我需要一个可以将它们导入普通用户(而不是SYSDBA)的解决方案,以便我可以使用其他工具来提取数据 .

我的数据库是11g,但如果需要,我可以找到10g数据库 . 我有TOAD for Oracle Xpert 11.6.1.6作为我的处理 . 我是一名经验丰富的Oracle程序员,但之前我还没有使用过EXP / IMP .

(以下信息已被隐藏以保护数据 . )

以下是转储文件的创建方式:

exp FILE=data.dmp \
LOG=data.log \
TABLES=USER1.TABLE1,USER1.TABLE2,USER1.TABLE3,USER1.TABLE4 \
INDEXES=N TRIGGERS=N CONSTRAINTS=N GRANTS=N

这是日志:

Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in WE8MSWIN1252 character set and AL16UTF16 NCHAR character set
Note: grants on tables/views/sequences/roles will not be exported
Note: indexes on tables will not be exported
Note: constraints on tables will not be exported

About to export specified tables via Conventional Path ...
Current user changed to USER1
. . exporting table                      TABLE1        271 rows exported
. . exporting table                      TABLE2     272088 rows exported
. . exporting table                      TABLE3       2770 rows exported
. . exporting table                      TABLE4      21041 rows exported
Export terminated successfully without warnings.

先感谢您 .

1 回答

  • 2

    更新:TOAD版本9.7.2将读取EXP生成的“dmp”文件 .

    从菜单中选择DATABASE - > EXPORT - > EXPORT FILE BROWSER .

    您需要安装TOAD的DBA实用程序 . 没有真正保证文件被正确解析,但数据将在架构浏览器中显示在TOAD中 .

    NOTEexp 实用程序生成的dmp文件唯一的其他已知实用程序是 imp 实用程序 . 您 cannot 自己读取转储文件 . 如果这样做,则存在错误地解析文件的风险 .

    如果您已在ORACLE表中拥有数据:

    要将表数据提取到文件中,请创建一个调用SQL * PLUS的shell脚本,并使SQL * PLUS将表数据假脱机到一个文件 . 每个表需要一个脚本 .

    #!/bin/sh
    #NOTE: The path to sqlplus will vary on your system,
    #      but it is generally $ORACLE_HOME/bin/sqlplus.
    #YOU NEED TO UNCOMMENT THESE LINES AND SET APPROPRIATELY.
    #export ORACLE_SID=YOUR_SID
    #export ORACLE_HOME=PATH_TO_YOUR_ORACLE_HOME
    #export PATH=$PATH:$ORACLE_HOME/bin
    sqlplus -s user/pwd@db << EOF
    set pagesize 0
    set linesize 0
    set linesize 255
    set heading off
    set echo off
    SPOOL TABLE1_DATA.txt
    REM FOR EACH COLUMN IN TABLE1, SET THE FORMAT
    COL FIELD_ID   format 999,999,999
    COL FIELD_DATA format a99
    select FIELD_ID,FIELD_DATA from TABLE1;
    SPOOL OFF
    EOF
    

    确保设置每行的行大小并设置每列的格式 . 有关数字格式列,请参阅上面的FIELD_ID;有关字符列,请参阅FIELD_DATA . 注意:您需要从文件末尾删除“N行选择” .

    (您仍然可以使用 imp 实用程序将您创建的文件导入另一个模式 . )

相关问题