如何在 Oracle 11g r2 Express 版本中更改字符集

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9117416/
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 03:54:35  来源:igfitidea点击:

How to change character set in Oracle 11g r2 Express edition

oracleplsqloracle11g

提问by alessandroasm

I have to change the character set from AL32UTF8 to WE8MSWIN1252 in a Oracle 11g r2 Express instance... I tried to use the command:

我必须在 Oracle 11g r2 Express 实例中将字符集从 AL32UTF8 更改为 WE8MSWIN1252...我尝试使用以下命令:

ALTER DATABASE CHARACTER SET WE8MSWIN1252;

But it fails saying that MSWIN1252 isn't a superset of AL32UTF8. Then I found some articles talking about CSSCAN, and that tool doesn't seem to be available in Oracle 11 Express.

但它没有说 MSWIN1252 不是 AL32UTF8 的超集。然后我发现了一些关于 CSSCAN 的文章,并且该工具在 Oracle 11 Express 中似乎不可用。

http://www.oracle-base.com/articles/10g/CharacterSetMigration.php

http://www.oracle-base.com/articles/10g/CharacterSetMigration.php

Anyone has an idea on how to do that? Thanks in advance

任何人都知道如何做到这一点?提前致谢

EditClarifying a little bit: The real issue is that I'm trying to import data into a table that has a column defined as VARCHAR(6 byte). The string causing the issue is 'eq.mês', it needs 6 bytes in MSWIN1252 and 7 bytes in UT8

编辑澄清一点:真正的问题是我试图将数据导入到一个表中,该表的列定义为 VARCHAR(6 字节)。导致问题的字符串是“eq.mês”,它在 MSWIN1252 中需要 6 个字节,在 UT8 中需要 7 个字节

采纳答案by Justin Cave

You can't.

你不能。

The Express Edition of 11g is only available using a UTF-8 character set. If you want to go back to the express edition of 10g, there was a Western European version that used the Windows-1252 character set. Unlike with the other editions, Oracle doesn't support the full range of character sets in the Express Edition nor does it support changing the character set of an existing XE database.

11g 的 Express Edition 仅可使用 UTF-8 字符集。如果你想回到 10g 的 express 版本,有一个使用 Windows-1252 字符集的西欧版本。与其他版本不同,Oracle 不支持 Express Edition 中的全部字符集,也不支持更改现有 XE 数据库的字符集。

Why do you believe you need to change the database character set? Other than potentially taking a bit more storage space to support the characters in the upper half of the Windows-1252 range, which generally aren't particularly heavily used, there aren't many downsides to a UTF-8 database.

为什么您认为需要更改数据库字符集?除了可能需要更多的存储空间来支持 Windows-1252 范围上半部分的字符(通常不是特别频繁使用)之外,UTF-8 数据库没有太多缺点。

回答by lssilveira

The problem of only execute that ALTER DATABASE command is that the Data Dictionary was not converted and it can be corrupted.

只执行那个 ALTER DATABASE 命令的问题是数据字典没有被转换并且它可能被损坏。

I had the same problem. In my case, we are using a Oracle 11g Express Edition (11.2.0.2.0) and we really need that it runs on WE8MSWIN1252 character set, but I cannot change the character set on installation (it always install with AL32UTF8).

我有同样的问题。就我而言,我们使用的是 Oracle 11g Express Edition (11.2.0.2.0),我们确实需要它在 WE8MSWIN1252 字符集上运行,但我无法在安装时更改字符集(它始终与 AL32UTF8 一起安装)。

With a Oracle Client 11g installed as Administrator and run only the csscan full=y(check this link https://oracle-base.com/articles/10g/character-set-migration) and we notice that are lossy and convertible data problems in our database. But, the problems are with the MDSYS (Oracle Spatial) and APEX_040000 (Oracle Application Express) schemas. So, as we dont need this products, we remove them (check this link: http://fast-dba.blogspot.com.br/2014/04/how-to-remove-unwanted-components-from.html).

以管理员身份安装 Oracle 客户端 11g 并仅运行csscan full=y(检查此链接https://oracle-base.com/articles/10g/character-set-migration),我们注意到数据库中存在有损和可转换数据问题。但是,问题在于 MDSYS (Oracle Spatial) 和 APEX_040000 (Oracle Application Express) 模式。因此,由于我们不需要这些产品,我们将其删除(查看此链接:http: //fast-dba.blogspot.com.br/2014/04/how-to-remove-unwanted-components-from.html)。

Then, we export with expdpthe users schemas and drop the users (they must be recreated at the end of the process).

然后,我们导出expdp用户模式并删除用户(必须在流程结束时重新创建)。

Executing csscan again with full=y capture=y, it reports that: The data dictionary can be safely migrated using the CSALTER script. If the report doesnt have this, the csalter.plb script will not work, because there are some conditions that will not be satisfied:

再次执行 csscan full=y capture=y,它报告说:The data dictionary can be safely migrated using the CSALTER script。如果报告没有这个,csalter.plb 脚本将无法工作,因为有一些条件不会被满足:

  • changeless for all CHAR VARCHAR2, and LONG data (Data Dictionary and Application Data)
  • changeless for all Application Data CLOB
  • changeless and/or convertible for all Data Dictionary CLOB
  • 对所有 CHAR VARCHAR2 和 LONG 数据(数据字典和应用程序数据)保持不变
  • 对所有应用程序数据 CLOB 保持不变
  • 所有数据字典 CLOB 不变和/或可转换

In our case, this conditions were satisfied and we could ran the CSALTER script successfully. Moreover, this script executes the ALTER DATABASE command you are trying to run and it converts the CLOB data of Data Dictionary that is convertible.

在我们的例子中,这个条件得到满足,我们可以成功运行 CSALTER 脚本。此外,此脚本执行您尝试运行的 ALTER DATABASE 命令,并转换可转换的数据字典的 CLOB 数据。

Finally, we create the users and the tablespaces of our application and we import the dump of the user data successfully.

最后,我们创建应用程序的用户和表空间,并成功导入用户数据的转储。

回答by Benoit

I would say that your best option when you want to go to a character set that supports only a subset of the original characters, that your best option is to use exp and imp back (or expdp and impdp).

我会说,当您想要使用仅支持原始字符子集的字符集时,最好的选择是使用 exp 和 imp back(或 expdp 和 impdp)。

Are you sure that no single table will contain any character not found in the 1252 code page ?

您确定没有单个表将包含在 1252 代码页中找不到的任何字符吗?