在Linux下修改oracle的字符集

先看看文档,明白一些原理,然后去折腾。

1Changing the Character Set After Database Creation

In some cases, you may wish to change the existing database character set. For instance, you may find that the number of languages that need to be supported in your database have increased. In most cases, you will need to do a full export/import to properly convert all data to the new character set. However, if, and only if, the new character set is a strict superset of the current character set, it is possible to use the ALTER DATABASE CHARACTER SET statement to expedite the change in the database character set. 

The target character set is a strict superset if and only if each and every codepoint in the source character set is available in the target character set, with the same corresponding codepoint value. For instance, the following migration scenarios can take advantage of the ALTER DATABASE CHARACTER SET statement because US7ASCII is a strict subset of WE8ISO8859P1, ZHS16GBK, and UTF8: 

Table 3-8 Sample Migration Scenarios 
Current Character Set  New Character Set   New Character Set is Strict Superset? 

US7ASCII                  WE8ISO8859P1                         Yes 

US7ASCII                   ZHS16GBK                                Yes 

US7ASCII                    UTF8                                      Yes 

Attempting to change the database character set to a character set that is not a strict superset can result in data loss and data corruption. To ensure data integrity, whenever migrating to a new character set that is not a strict superset, you must use export/import. It is essential to do a full backup of the database before using the ALTER DATABASE [NATIONAL] CHARACTER SET statement, since the command cannot be rolled back. The syntax is: 

ALTER DATABASE [<db_name>] CHARACTER SET <new_character_set>;
ALTER DATABASE [<db_name>] NATIONAL CHARACTER SET <new_NCHAR_character_set>;


The database name is optional. The character set name should be specified without quotes, for example: 

ALTER DATABASE CHARACTER SET WE8ISO8859P1;


To change the database character set, perform the following steps. Not all of them are absolutely necessary, but they are highly recommended: 

SQL> SHUTDOWN IMMEDIATE;   -- or NORMAL
    <do a full backup>

SQL> STARTUP MOUNT;
SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;
SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
SQL> ALTER DATABASE OPEN;
SQL> ALTER DATABASE CHARACTER SET <new_character_set_name>;
SQL> SHUTDOWN IMMEDIATE;   -- or NORMAL
SQL> STARTUP;


To change the national character set, replace the ALTER DATABASE CHARACTER SET statement with the ALTER DATABASE NATIONAL CHARACTER SET statement. You can issue both statements together if desired.

描述:数据从开发部的服务器导入到我的双向流测试。linux下的Jdk,jboss都安装好,就等部署,上周从开发部

拉了一小伙,整了半天,未果。这周直接找他们老大,应用部署完了,说明jboss安装没问题,中 文数据全是乱码

讨论了一下解决方法,开发部主张recreate database或者 把用户删除cascade,再导入数据。我的天,我想了一下

把表删除,修改字符集,重新导入。

开发部服务器字符集

 select userenv('language') from dual

 AMERICAN_CHINA.ZHS16GBK

 双向流服务器字符集

 WE8ISO8859P1

二者的关系既不是超集也不是所属子集关系,官方说修改会无效,还是试一下,想着建库,流复制,头很大。

2 参照官方还是有点头绪,也走了一些弯路。

-----------------------------------------------------------------------------------------------------

1 关闭数据库

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

2

SQL> startup nomount;
ORA-32004: obsolete and/or deprecated parameter(s) specified
ORACLE instance started.

Total System Global Area 1174405120 bytes
Fixed Size                  1219040 bytes
Variable Size             570426912 bytes
Database Buffers          587202560 bytes
Redo Buffers               15556608 bytes
Database mounted.
3

SQL> alter system enable restricted session;

System altered.

SQL> alter system set job_queue_processes=0;

System altered.

SQL> alter system set aq_tm_processes=0;

System altered.

4SQL> alter database open;

5 alter database character set ZHS16GBK;
alter database character set ZHS16GBK
*
ERROR at line 1:
ORA-12721: operation cannot execute when other sessions are active---------N次出现这个问题

无法进行下去了。

------------------------------------------------------------------------------------------------------------------------------

6 再关闭数据库,直接startup,还是报ORA-12721的错误。

7再试,Ok

SQL> startup mount;
ORA-32004: obsolete and/or deprecated parameter(s) specified
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> shutdown immediate;
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup mount;
ORA-32004: obsolete and/or deprecated parameter(s) specified
ORACLE instance started.

Total System Global Area 1174405120 bytes
Fixed Size                  1219040 bytes
Variable Size             570426912 bytes
Database Buffers          587202560 bytes
Redo Buffers               15556608 bytes
Database mounted.
SQL> alter system enable restricted session;

System altered.

SQL> alter system set job_queue_processes=0;

System altered.

SQL> alter system set aq_tm_processes=0;

System altered.

SQL> alter database open;

Database altered.

SQL> alter database orcl character set internal_use ZHS16GBK;

Database altered.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORA-32004: obsolete and/or deprecated parameter(s) specified
ORACLE instance started.

Total System Global Area 1174405120 bytes
Fixed Size                  1219040 bytes
Variable Size             570426912 bytes
Database Buffers          587202560 bytes
Redo Buffers               15556608 bytes
Database mounted.
Database opened.

 

最后PL/SQL中文都能正常显示,不是乱码了。忙了快一天了,整理一下。

 

 

 

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
安装Oracle数据库的过程可以分为以下几个步骤: 1. 在Oracle官网下载适用于Linux系统的Oracle数据库软件安装包,并解压缩文件。 2. 配置Linux系统的环境变量,包括ORACLE_HOME、ORACLE_SID以及PATH等。ORACLE_HOME指定Oracle软件的安装路径,ORACLE_SID指定要使用的数据库实例名称,而PATH需要包含ORACLE_HOME/bin目录。 3. 创建一个新的操作系统用户用于管理Oracle数据库。这个用户通常被称为"oracle"。 4. 设置Linux系统的内核参数。根据Oracle官方提供的建议,需要修改一些内核参数,以确保数据库的正常运行。 5. 创建一个文件系统用于存储Oracle数据库的数据文件和日志文件。这个文件系统需要具备足够的空间来容纳数据库所需的数据。 6. 在创建的文件系统上创建适当的目录结构,并授予"oracle"用户对这些目录的访问权限。 7. 运行Oracle数据库软件的安装程序,并按照向导的指示进行安装。在安装过程中,需要指定Oracle数据库的安装类型、数据库实例名称、监听器配置等信息。 8. 安装完成后,需要运行Oracle Database Configuration Assistant(DBCA)创建数据库实例。DBCA会引导您完成数据库的配置,包括设置数据库名、字符集、内存分配等。 9. 启动Oracle数据库实例,并配置监听器以便客户端能够连接到数据库。 10. 使用sqlplus工具登录到Oracle数据库,进行进一步的配置和管理操作。 请注意,以上步骤仅为概述,具体的安装过程可能会因为不同的操作系统版本和Oracle数据库版本而略有差异。建议您在安装之前,参考Oracle官方的安装指南以获取最新的安装说明。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值