Oracle sqlplus execute files of different encoding
Solution 1
You have to change encoding with command chcp
, e.g. chcp 65001
for UTF-8 or chcp 1252
for Windows 1252. Term "ANSI" is just a general name for many different encodings. See column "ANSI codepage" at this National Language Support (NLS) API Reference to get codepage for you locale.
If you have to change the encoding inside a SQL script use host chcp ...
However, you also have to set NLS_LANG
environment variable accordingly. So after you have changed codepage you must also run for example SET NLS_LANG=.AL32UTF8
or SET NLS_LANG=.WE8MSWIN1252
.
See OdbcConnection returning Chinese Characters as "?" for more details.
Solution 2
I have a SQL script created in UTF8, to run it with sqlplus in Linux, before open sqlplus do
export NLS_LANG=.AL32UTF8
then use sqlplus to load the script.
user1753180
Updated on July 20, 2022Comments
-
user1753180 almost 2 years
I have a batch file that execute SQL scripts through sqlplus:
( echo @"./myUTF8.sql" echo @"./myAnsi.sql" ) | sqlplus uset/pwd@mybd
Unfortunately these SQL scripts are generated in different encoding, Ansi, UTF8, ...
How can I tell sqlplus that a script is of a specified encoding?