Oracle dump file table data extraction to file (original exp format)
我有使用原始exp(不是expdp)(EXPORT:V10.02.01,Oracle 10g)创建的Oracle转储文件。 它们仅包含四个表的表数据。
1)我想将表数据提取到文件(固定宽度/固定宽度,CVS或其他文本文件)中,而不将它们导入另一个Oracle DB中。 [首选]
2)另外,我需要一个可以将其导入到普通用户(而不是SYSDBA)中的解决方案,以便可以使用其他工具来提取数据。
我的数据库是11g,但是如果需要,我可以找到10g数据库。 我可以使用TOAD for Oracle Xpert 11.6.1.6。 我是一位经验丰富的Oracle程序员,但是我以前从未使用过EXP / IMP。
(以下信息已被遮盖,以保护数据。)
转储文件的创建方式如下:
1 2 3 4 | exp FILE=data.dmp \\ LOG=data.log \\ TABLES=USER1.TABLE1,USER1.TABLE2,USER1.TABLE3,USER1.TABLE4 \\ INDEXES=N TRIGGERS=N CONSTRAINTS=N GRANTS=N |
这是日志:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | 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. |
先感谢您。
更新:
TOAD版本9.7.2将读取EXP生成的" dmp"文件。
从菜单中选择数据库->导出->导出文件浏览器。
您需要安装用于TOAD的DBA实用程序。不能真正保证文件已被解析
正确,但是数据将显示在模式浏览器的TOAD中。
注意:
如果您已经在ORACLE表中包含数据:
要将表数据提取到文件中,请创建一个外壳程序脚本,该脚本调用SQL * PLUS并使SQL * PLUS将表数据假脱机到文件中。每个表需要一个脚本。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #!/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行"。
(您仍然可以使用