修改oracle数据库的字符编码
程序员文章站
2022-07-13 12:06:31
...
最近安装个Oracle 10g数据库,dbca建库的时候没选字符集或者选错的情况,导入数据后,中文全部是乱码或者不能正常导入新的库,出现表字段长度不够的错误,解决办法如下:
SQL> connect / as sysdba; ---dba用户连接数据库
SQL> select name,value$ from props$ where name like '%NLS%';---语句查询当前数据库服务器字符集
NAME
------------------------------------------------------------
VALUE$
--------------------------------------------------------------------------------
NLS_LANGUAGE
AMERICAN
NLS_TERRITORY
AMERICA
NLS_CURRENCY
$
NAME
------------------------------------------------------------
VALUE$
--------------------------------------------------------------------------------
NLS_ISO_CURRENCY
AMERICA
NLS_NUMERIC_CHARACTERS
.,
NLS_CHARACTERSET ----找到查出来的结果中的该项参数
WE8ISO8859P1
下面是修改过程:
SQL> shutdown immediate; ---停止数据库
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount ---启动数据库到mount状态
ORACLE instance started.
Total System Global Area 235999352 bytes
Fixed Size 450680 bytes
Variable Size 201326592 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
---下面是修改过程,按步骤修改
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可以跳过超集的检查,
(ALTER DATABASE character set INTERNAL_USE )
Database altered.
SQL> shutdown immediate; ---再停止数据库
Database closed.
Database dismounted.
ORACLE instance shut down.
---启动数据库
SQL> STARTUP
ORACLE instance started.
Total System Global Area 235999352 bytes
Fixed Size 450680 bytes
Variable Size 201326592 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL>
----再次查看当前字符集
SQL> select name,value$ from props$ where name like '%NLS%';
NAME
------------------------------
VALUE$
--------------------------------------------------------------------------------
NLS_LANGUAGE
SIMPLIFIED CHINESE
NLS_TERRITORY
CHINA
NLS_CURRENCY
?
NAME
------------------------------
VALUE$
--------------------------------------------------------------------------------
NLS_ISO_CURRENCY
CHINA
NLS_NUMERIC_CHARACTERS
.,
NLS_CHARACTERSET
ZHS16GBK ---【已经修改成为中文编码了】
原文链接:http://www.linuxidc.com/Linux/2011-07/38114.htm
SQL> connect / as sysdba; ---dba用户连接数据库
SQL> select name,value$ from props$ where name like '%NLS%';---语句查询当前数据库服务器字符集
NAME
------------------------------------------------------------
VALUE$
--------------------------------------------------------------------------------
NLS_LANGUAGE
AMERICAN
NLS_TERRITORY
AMERICA
NLS_CURRENCY
$
NAME
------------------------------------------------------------
VALUE$
--------------------------------------------------------------------------------
NLS_ISO_CURRENCY
AMERICA
NLS_NUMERIC_CHARACTERS
.,
NLS_CHARACTERSET ----找到查出来的结果中的该项参数
WE8ISO8859P1
下面是修改过程:
SQL> shutdown immediate; ---停止数据库
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount ---启动数据库到mount状态
ORACLE instance started.
Total System Global Area 235999352 bytes
Fixed Size 450680 bytes
Variable Size 201326592 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
---下面是修改过程,按步骤修改
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可以跳过超集的检查,
(ALTER DATABASE character set INTERNAL_USE )
Database altered.
SQL> shutdown immediate; ---再停止数据库
Database closed.
Database dismounted.
ORACLE instance shut down.
---启动数据库
SQL> STARTUP
ORACLE instance started.
Total System Global Area 235999352 bytes
Fixed Size 450680 bytes
Variable Size 201326592 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL>
----再次查看当前字符集
SQL> select name,value$ from props$ where name like '%NLS%';
NAME
------------------------------
VALUE$
--------------------------------------------------------------------------------
NLS_LANGUAGE
SIMPLIFIED CHINESE
NLS_TERRITORY
CHINA
NLS_CURRENCY
?
NAME
------------------------------
VALUE$
--------------------------------------------------------------------------------
NLS_ISO_CURRENCY
CHINA
NLS_NUMERIC_CHARACTERS
.,
NLS_CHARACTERSET
ZHS16GBK ---【已经修改成为中文编码了】
原文链接:http://www.linuxidc.com/Linux/2011-07/38114.htm
上一篇: SWFUpload资料
下一篇: Hibernate动态创建视图