perl unload gbk Oracle 数据库
use Encode;
if ( $#ARGV < 0 ){
print "请输入一个文件
";
exit(-1);
}
$var = $ARGV[0];
open (FILE ,"<","$var") || die "can open file$!
";
while (<FILE>) {
$str = encode("gbk",decode("utf8","$_"));
print "$str" ;
}
close FILE;
需要的utf-8环境 把脚本格式转换成gbk
Oracle shell 上设置:
export NLS_LANG="SIMPLIFIED CHINESE_CHINA".ZHS16GBK
查看数据库字符集:
客户端字符集
SQL> select userenv('language') from dual;
USERENV('LANGUAGE')
----------------------------------------------------
AMERICAN_AMERICA.ZHS16GBK
服务端字符集
SQL> col parameter format a40
SQL> col value format a20
SQL> select * from nls_database_parameters where parameter='NLS_CHARACTERSET';
PARAMETER VALUE
---------------------------------------- --------------------
NLS_CHARACTERSET ZHS16GBK