修改oracle9i数据库字符集

首先确认oracle用户的环境变量里有以下语句(/home/oracle/.bash_profile里有相关设置即可)export NLS_LANG=american_america.ZHS16GBK 或者是 export NLS_LANG="Simplified Chinese_china".ZHS16GBK


修改数据库字符集的步骤如下:
[oracle@data oracle]$ sqlplus "/as sysdba"
SQL> startup

SQL> col value$ format a40
SQL> select name,value$ from props$ where name like '%NLS%';

上图中的参数“NLS_CHARACTERSET               ZHS16GBK”是修改之后的结果,没有修改前是"NLS_CHARACTERSET WE8ISO8859P1"

具体的步骤如下:
SQL> shutdown immediate;

SQL> startup mount

SQL> alter session set sql_trace=true;

Session altered.

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> set linesize 120;
SQL> alter database character set zhs16gbk;
alter database character set zhs16gbk
*
ERROR at line 1:
ORA-12712: new character set must be a superset of old character set

SQL> alter DATABASE character set INTERNAL_USE zhs16gbk; # 使用INTERNAL_USE可以跳过超集的检查,用以强制完成字符集一致化。

Database altered.

SQL> shutdown immediate;

SQL> STARTUP

SQL> select value from nls_database_parameters where parameter='NLS_CHARACTERSET';

VALUE

--------------------------------------------------------------------------------
ZHS16GBK
修改成功!

你可能感兴趣的:(oracle,职场,休闲)