1:查看數據庫字符集設置
2:安裝好ORACLE軟件或者直接使用ORACLE客戶端,設置好監聽和pl/sql developer.
也就是在環境變量中增加這行即可:NLS_LANG SIMPLIFIED CHINESE_CHINA.ZHS16GBK
二:LINUX下的SQLPLUS客戶端連接
1:查看數據庫字符集設置
2:設置環境變量,ORACLE用戶登錄
$ vim .bash_profile --添加如下行即可
export NLS_LANG="Simplified Chinese_china".AL32UTF8
嘗試過使用添加如下,依然亂碼解決不了問題
export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
正確配置如下:
[oracle@mlyds mobileall]$ rpm -qa |grep fonts-chinese
[oracle@mlyds mobileall]$ echo LANG
en_US.UTF-8
[oracle@mlyds mobileall~]$ cat .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export ORACLE_BASE=/u01/oracle
export ORACLE_SID=test
export NLS_LANG="Simplified Chinese_china".AL32UTF8
#export NLS_LANG="SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
export ORACLE_HOME=$ORACLE_BASE/product/10g
export PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
三:驗證以及使用unix2doc進行換行符轉換:
[oracle@mlyds mobileall]$ sqlplus wonder
SQL*Plus: Release 11.2.0.1.0 Production on 星期三 5月 23 18:07:08 2012
Copyright (c) 1982, 2009, Oracle. All rights reserved.
輸入口令:
如果此時使用SPOOL導出TXT數據,可以使用unix2doc filename 進行換行符轉換,使其傳到window下後方面查看
SQL>@/tmp/aa.sql
aa.sql
set heading off
set echo off
set term off
set termout off
set termsout off
set newpage none
set linesize 11
set pagesize 0
set feed off
spool /tmp/mobileall/mp3/北京一次.txt
select distinct(mobile) from qunfa_mtx_test t where t.provincename='北京' and vst=1 and url_class='mp3';
spool /tmp/mobileall/mp3/北京二次.txt
select distinct(mobile) from qunfa_mtx_test t where t.provincename='北京' and vst=2 and url_class='mp3';
spool off
上述步驟經過驗證