Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set charset to UTF-8 in SQL*Plus

I have a SQL script that contains the following statement:

insert into employee(fname,lname) values('Jörg','Müller');

My Database Charset ist set to AL32UTF8 but when I execute the script in SQLPlus the german letters Ö and Ü are not saved correctly. How can I set the Charset of SQLPlus to UTF-8?

Is it possible to set the SQL*Plus Charset to UTF-8 in my script file (the sql script file contains the command to set the charset to UTF-8)?

My runtime environment is Window but script should also be able to run on unix. My oracle version is 19c.

like image 314
Elmo N'diaye Avatar asked Oct 16 '25 00:10

Elmo N'diaye


1 Answers

SQL*Plus inherits the character set from cmd window. You need to set encoding to UTF-8 and tell it Oracle. This is done by NLS_LANG parameter.

Try this:

chcp 65001
set NLS_LANG=.AL32UTF8
sqlplus ....

Of course, this works only if your sql-file is also saved as UTF-8. Otherwise you need to adapt character sets from above.

See OdbcConnection returning Chinese Characters as "?"

like image 60
Wernfried Domscheit Avatar answered Oct 18 '25 18:10

Wernfried Domscheit