1.下载安装sqluldr2
cd /u01/app/oracle/scripts
---
chmod +x sqluldr2linux64.bin
---
./sqluldr2linux64.bin -help
[oracle@compiler1002 expdp]$ ./sqluldr2linux64.bin -help
SQL*UnLoader: Fast Oracle Text Unloader (GZIP, Parallel), Release 4.0.1
(@) Copyright Lou Fangxin (AnySQL.net) 2004 - 2010, all rights reserved.
License: Free for non-commercial useage, else 100 USD per server.
Usage: SQLULDR2 keyword=value [,keyword=value,...]
Valid Keywords:
user = username/password@tnsname
sql = SQL file name
query = select statement
field = separator string between fields
record = separator string between records
rows = print progress for every given rows (default, 1000000)
file = output file name(default: uldrdata.txt)
log = log file name, prefix with + to append mode
fast = auto tuning the session level parameters(YES)
text = output type (MYSQL, CSV, MYSQLINS, ORACLEINS, FORM, SEARCH).
charset = character set name of the target database.
ncharset= national character set name of the target database.
parfile = read command option from parameter file
for field and record, you can use '0x' to specify hex character code,
\r=0x0d \n=0x0a |=0x7c ,=0x2c, \t=0x09, :=0x3a, #=0x23, "=0x22 '=0x27
2. 编辑sql文件
vi exportcsv.sql
select * from tableA;
3. 导出数据成csv
./sqluldr2linux64.bin user=user/passowd@PDMSDB sql=exportcsv.sql file=data20210424-26.csv text=csv
4. 压缩
tar -czvf data20210424-26.csv.tar.gz data20210424-26.csv
5. 解决csv文件打开是乱码的问题
将数据库的数据导出为CSV文件,之后用excel打开,出现了乱码情况.
原因:CSV是用UTF-8编码的,而EXCEL是ANSI编码,由于编码方式不一致导致出现乱码。
解决办法:用记事本打开CSV文件----->文件------>另存为------>点编码------>选择ANSI----->保存,然后用excel打开就不会是乱码了。