Unload Oracle data into text file

how to unload oracle data into fixed length text file

1. sqluldr2
This tool developed by one Chinese Oracle guru. At a glance, this tool is suited for my need exactly.
http://www.dbatools.net
http://www.dbatools.net/mytools/parallel-inside-sqluldr2.html

**tricks and issues:
  trick 1: choose space(0x20) as field separator, the tool will output fixed-length text file
 
  trick 2: 可以将一些参数放在一个参数文件中, 然后给这个工具指定parfile参数来加载这个参数文件, 如果某个参数在参数文件和命令行中都进行了设定, 以命令行的设定为准.  
      比如命令行: sqluldr2.exe  parfile=parfile.txt  log=table1.log  file=table1.txt query="select * from table1"
      比如参数文件:
        user=usr_a/pwd_b@tns_c
        field=0x20
        record=0x0A
        
  trick 3: 如果输出文件的扩展名为gz, 这个工具自动会将数据包做压缩处理, 采用的gzip算法, 但我测试, 这个feature没有任何作用(我用的sqluldr2.exe是2011-3-24日创建的).  

  trick 4:将用户/密码等放在参数文件是一个好的做法, 但密码是明文也不符合安全要求. 现在这个工具支持加密数据库连接信息. 但我测试, 这个feature没有任何作用(我用的sqluldr2.exe是2011-3-24日创建的).详见
     http://www.dbatools.net/mytools/sqluldr2-password-protection.html
     步骤 a: 生成加密连接串  
          D:\>sqluldr2 user=scott/tiger@//localhost:1521/db10g crypt=create
          会生成下面2行字符串
        4899919fa603950b53e639d80245beae8b5d8bb7437bf79e92a473d60377e269
        499ee76090faa97f7f043eeae19ffa5445ac5e9d89921dce7f043eeae19ffa54
      步骤 b: 将连接字符串放在参数文件中, 同时加上crypt=on的设置
        crypt=on
        user=concat the two encrypted lines here
        query=select * from emp
        
  trick 5: 大数据表的导出, 可以使用split和degree参数, 详见
  http://www.dbatools.net/mytools/parallel-inside-sqluldr2.html
  我在测试parallel特性时候, 当degree设置大于1时候, 生成的text文件时空的. 当degree设置为1时, 报ORA-01008: not all variables bound. 另外, 我有一个疑问, 如果在sql中, 表使用了alias, split值应该是表名, 还是表的alias名?
D:\>sqluldr2.exe  parfile=parfile.txt  log=table_test.%p.log  file=table_test.%p.txt  query="select * from table_test where 1=1 and rowid>=:minrid and rowid<:maxrid" degree=2 split=table_test
 
  trick 6: If it is need to output fix-length text file, The tool cannot identify string column length when statement is provided by sql parameter, i think it is a bug. In this situation, use query parameter rather than sql parameter.
  当输出定长格式的文本时候, 如果使用sql参数的话, 对于输出文本类型字段, 经常会长度超级长的情况(4000个字符长), 而使用query参数的时候, 没有碰到这种情况, 我认为可能是个bug, 程序没有正确地获取字段的长度信息. 比如,
  select str_field from table_test, str_field的类型为varchar2(10),

  trick 7: 关于text文件的编码问题, 好像缺少相关的设置选项吗, 比如设置输出为ansi, utf-8或unicode, 尚不清楚导出中文会不会有问题.
        
        
2. ORA2TD
I find this tool by Google, but no more detailed info found. http://www.teradataforum.com/teradata/20020314_144449.htm

3. sqlplus spool
At performance aspect, I am not sure that this tool will work well to unload large volume data.

4. oraunload

I think other Oracle official tools except sqlplus cannot meet our needs, please find the detailed at the following link,
http://download.oracle.com/docs/cd/B25329_01/doc/admin.102/b25107/impexp.htm
原文地址:https://www.cnblogs.com/harrychinese/p/Unload_Oracle_data_into_text_file.html