Oracle SQL Developer 环境编码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9631515/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 04:02:03  来源:igfitidea点击:

Oracle SQL Developer environment encoding

oracleencoding

提问by ULazdins

I have Oracle SQL Developer (3.1.07) and I'm trying to work with a database that uses WE8ISO8859P1encoding:

我有 Oracle SQL Developer (3.1.07),我正在尝试使用使用WE8ISO8859P1编码的数据库:

SELECT * FROM nls_database_parameters WHERE parameter = 'NLS_CHARACTERSET';

I have problems with saving packages that contains unicode symbols. When I open previously saved package all unicode symbols are turned to '?'.

我在保存包含 unicode 符号的包时遇到问题。当我打开以前保存的包时,所有 unicode 符号都变为'?'.

What settings do I have to change to make SQL Developer keep those symbols? I've tried to set environment encoding to 'ISO-8859-15'and some other encodings, but it won't help.

我必须更改哪些设置才能让 SQL Developer 保留这些符号?我尝试将环境编码设置为'ISO-8859-15'和其他一些编码,但无济于事。

回答by mycelo

If your database encodes text to a non-unicode single-byte encoding (e.g. ISO-8859), any symbol not present on the character table will be seen as invalid and replaced by a placeholder. You can't go back from that, the information is lost.

如果您的数据库将文本编码为非 unicode 单字节编码(例如 ISO-8859),则字符表中不存在的任何符号都将被视为无效并被占位符替换。你不能从那里回来,信息丢失了。

That can be usually worked around when storing data, but as for source code, you cannot control how Oracle would encode your strings.

这通常可以在存储数据时解决,但对于源代码,您无法控制 Oracle 如何编码您的字符串。

If your database is configured to use such encoding scheme you're probably not supposed to write code that violates its rules.

如果您的数据库配置为使用这种编码方案,您可能不应该编写违反其规则的代码。

回答by Deblaton Jean-Philippe

Maybe you could need this character set migration

也许你可能需要这个字符集迁移

http://docs.oracle.com/cd/B10501_01/server.920/a96529/ch10.htm#1656

http://docs.oracle.com/cd/B10501_01/server.920/a96529/ch10.htm#1656

on the Oracle's documentation

在 Oracle 的文档中

回答by pahariayogi

At least to open PKG in sql developer, you can do a quick try and see if it works:-

至少要在sql developer中打开PKG,您可以快速尝试一下,看看它是否有效:-

Change SQL Developer 'encoding' to 'unicode-utf-8' which is default to later versions now.

将 SQL Developer 'encoding' 更改为 'unicode-utf-8' 现在默认为更高版本。

You would ,eventually, need to go for database charset migration to 'AL32UTF8' to avoid other issues (like data) due to this char set.

最终,您需要将数据库字符集迁移到“AL32UTF8”以避免由于此字符集而导致的其他问题(如数据)。

回答by Gary Myers

If you look at USER_SOURCE you'll see that the source code, as stored/interpreted by the database, will be in a VARCHAR2 column so use the database character set. As such, your source code will need to be in WE8ISO8859P1.

如果您查看 USER_SOURCE,您将看到由数据库存储/解释的源代码将位于 VARCHAR2 列中,因此请使用数据库字符集。因此,您的源代码需要在 WE8ISO8859P1 中。

In theory, if the client and database are using the same character set, then the database won't try to do any character set translation and you may be able to sneak in a sequence of bytes that the database thinks are WE8ISO8859P1 but will make sense in unicode. However, at some point, someone will use the wrong client and it will break.

理论上,如果客户端和数据库使用相同的字符集,那么数据库将不会尝试进行任何字符集转换,您可能会偷偷输入数据库认为是 WE8ISO8859P1 但有意义的字节序列在 Unicode 中。然而,在某些时候,有人会使用错误的客户端,它会崩溃。

You don't need unicode for identifiers etc in the code, so I assume it is in string literals. You are better off storing these in a table (NVARCHAR2 column) and selecting them into the code rather than hard-coding them. If that isn't possible, you could use UNISTR and hard-code the relevant hex values.

代码中的标识符等不需要 unicode,所以我假设它是字符串文字。最好将它们存储在表(NVARCHAR2 列)中并将它们选择到代码中,而不是对它们进行硬编码。如果这是不可能的,您可以使用 UNISTR 并对相关的十六进制值进行硬编码。