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
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

浙公網安備 33010602011771號