如何更改Oracle字符集
1个回答
展开全部
复制一段吧:
通常情况下,字符集是在安装的时候选定好的,需要修改数据库的字符集Oracle建议的做法是重建数据库(EXP/EXPDP导出后再导入),虽然Oracle官方文档也有说如何修改字符集,但这不是Orale推荐的方法.下面是Oracle官方文档中提到的如何修改字符集的方法.
1.查看当前数据库字符集
select * from nls_database_parameters
where parameter='NLS_CHARACTERSET';
-----------------------------------
PARAMETER VALUE
NLS_CHARACTERSET WE8ISO8859P1
这里的字符集WE8ISO8859P1是不支持中文的
2.将字符集修改为中文字符集ZHS16GBK
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP MOUNT;
ORACLE instance started.
Total System Global Area 734003200 bytes
Fixed Size 1221564 bytes
Variable Size 264244292 bytes
Database Buffers 465567744 bytes
Redo Buffers 2969600 bytes
Database mounted.
SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;
System altered.
SQL> ALTER DATABASE OPEN;
Database altered.
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;
Database altered.
SQL> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 734003200 bytes
Fixed Size 1221564 bytes
Variable Size 264244292 bytes
Database Buffers 465567744 bytes
Redo Buffers 2969600 bytes
Database mounted.
Database opened.
这样将数据库的字符集由原来的WE8ISO8859P1修改成了ZHS16GBK,对原来的字符集有中文的显示的还是乱码,但对新入库的中文字符集就能正常显示.
通常情况下,字符集是在安装的时候选定好的,需要修改数据库的字符集Oracle建议的做法是重建数据库(EXP/EXPDP导出后再导入),虽然Oracle官方文档也有说如何修改字符集,但这不是Orale推荐的方法.下面是Oracle官方文档中提到的如何修改字符集的方法.
1.查看当前数据库字符集
select * from nls_database_parameters
where parameter='NLS_CHARACTERSET';
-----------------------------------
PARAMETER VALUE
NLS_CHARACTERSET WE8ISO8859P1
这里的字符集WE8ISO8859P1是不支持中文的
2.将字符集修改为中文字符集ZHS16GBK
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP MOUNT;
ORACLE instance started.
Total System Global Area 734003200 bytes
Fixed Size 1221564 bytes
Variable Size 264244292 bytes
Database Buffers 465567744 bytes
Redo Buffers 2969600 bytes
Database mounted.
SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;
System altered.
SQL> ALTER DATABASE OPEN;
Database altered.
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;
Database altered.
SQL> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 734003200 bytes
Fixed Size 1221564 bytes
Variable Size 264244292 bytes
Database Buffers 465567744 bytes
Redo Buffers 2969600 bytes
Database mounted.
Database opened.
这样将数据库的字符集由原来的WE8ISO8859P1修改成了ZHS16GBK,对原来的字符集有中文的显示的还是乱码,但对新入库的中文字符集就能正常显示.
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |