在Sql中插入UNICODE字符
我正在尝试将 unicode 字符串放入 SQL*Plus: Release 10.2.0.2.0 数据库中,但遇到困难。如果我使用 SQLPlus 并将插入语句复制并粘贴到数据库中,则任何特殊字符都会插入为 ?或类似的东西。然后我尝试调用一个已编码为UTF-8的sql文件,结果是相同的。 有谁知道如何将unicode数据存入数据库?
谁能帮忙。如何在 sqlplus 中设置 NLS_LANG 选项
I am trying to get unicode strings into an SQL*Plus: Release 10.2.0.2.0 database but am having difficulties. If I use SQLPlus and copy and paste the insert statement into the database, any special characters are inserted as ? or something like that. I then try to call a sql file that has been encoded to UTF-8 and the outcome is the same.
Does anyone know how to get unicode data into database?
Can anyone help . How can i set NLS_LANG option within sqlplus
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
SQL *Plus 不是数据库,它是 SQL 或 PL/SQL 数据库的基于命令行的前端。命令行通常仅支持 ANSI 或 ASCI 编码字符。因此,当您尝试粘贴命令时,程序(SQL *Plus)只是替换了文本,它无法弄清楚如何用“?”进行编码。标记。您可能需要切换到不同的客户端应用程序才能使用 UTF-8
SQL *Plus is not a database it's a command-line based front-end to a SQL or PL/SQL database. The command-line usually only supports ANSI or ASCI encoded characters. So when you try and paste in the command the program (SQL *Plus) just replaces the text it can't figure out how to encode with "?" marks. You probably need to switch to a different client application to use UTF-8
就我而言,问题不在
sqlplus
中,而是在数据库运行的环境中。设置后我可以插入 unicode 字符而不会出现任何失真。
可能需要重新启动一些才能生效(数据库或操作系统或两者)。我在 docker 中运行 Oracle XE 数据库,所以
我必须将
-e NLS_LANG=RUSSIAN_RUSSIA.UTF8
添加到docker run...
命令,如下所示:In my case the problem wasn't in
sqlplus
but in the environment in that the database was run. After I setI could insert unicode characters without any distortion.
Some restarts may be needed for this to take effect (db or OS or both). I run an Oracle XE db in docker so
I had to add
-e NLS_LANG=RUSSIAN_RUSSIA.UTF8
to thedocker run...
command as shown below:设置 NLS_LANG 环境变量以使 SQL*Plus 理解您正在使用的字符表示形式。
http://www.sqlsnippets.com/en/topic-13434.html
Set the NLS_LANG environmental variable to make SQL*Plus understand the character representation you're using.
http://www.sqlsnippets.com/en/topic-13434.html
尝试使用此语句周围的东西
try to using something around this statement