Linux中的db2命令读取SQL文件时如何指定字符集
How to specify the character set when db2 command in Linux read an SQL file
我在 Linux 中使用以下命令通过 db2 命令行处理器 (CLP) 在文件中执行 SQL:
db2 -f script.sql
script.sql 的编码是 Windows-1252 (CP1252)。当我 运行 服务器 A 上的命令时,db2 成功读取并执行文件,但是当我 运行 服务器 B 上的命令时,db2 无法读取文件,因为它无法识别编码在 Windows-1252.
两台服务器上的 LANG 环境变量相同 (en_GB)。两台服务器上的db2 CLP版本相同,操作系统相同
您可以在会话中设置相应的环境变量。
export DB2CODEPAGE=1252
—- just in case if you ran db2 commands previously
—- in this session
db2 terminate
—- if there is no connect command in the script
db2 connect to mydb
db2 -f script.sql
—- if you need other Db2 commands
—- with your default code page in this session
db2 connect reset
db2 terminate
unset DB2CODEPAGE
我在 Linux 中使用以下命令通过 db2 命令行处理器 (CLP) 在文件中执行 SQL:
db2 -f script.sql
script.sql 的编码是 Windows-1252 (CP1252)。当我 运行 服务器 A 上的命令时,db2 成功读取并执行文件,但是当我 运行 服务器 B 上的命令时,db2 无法读取文件,因为它无法识别编码在 Windows-1252.
两台服务器上的 LANG 环境变量相同 (en_GB)。两台服务器上的db2 CLP版本相同,操作系统相同
您可以在会话中设置相应的环境变量。
export DB2CODEPAGE=1252
—- just in case if you ran db2 commands previously
—- in this session
db2 terminate
—- if there is no connect command in the script
db2 connect to mydb
db2 -f script.sql
—- if you need other Db2 commands
—- with your default code page in this session
db2 connect reset
db2 terminate
unset DB2CODEPAGE