重庆思庄Oracle、KingBase、PostgreSQL、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 317|回复: 0
打印 上一主题 下一主题

[Oracle] Oracle数据库修改字符集编码

[复制链接]
跳转到指定楼层
楼主
发表于 2025-11-30 14:01:59 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
字符集编码格式一般都是ZHS16GBK,偶尔会遇到要改成AL32UTF8

复制代码
查看当前使用的字符集编码
SQL> select userenv('language') from dual;

USERENV('LANGUAGE')
----------------------------------------------------
AMERICAN_AMERICA.ZHS16GBK   

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

以挂载方式打开数据库
SQL> startup mount
ORACLE instance started.

Total System Global Area  776646656 bytes
Fixed Size            2257272 bytes
Variable Size          507514504 bytes
Database Buffers      260046848 bytes
Redo Buffers            6828032 bytes
Database mounted.

设置session
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 CHARACTER SET AL32UTF8;
ALTER DATABASE CHARACTER SET AL32UTF8
*
ERROR at line 1:
ORA-12712: new character set must be a superset of old character set

提示我们的字符集:新字符集必须为旧字符集的超集,跳过超集检查做更改:
SQL> ALTER DATABASE character set INTERNAL_USE AL32UTF8;
Database altered.

重新启动数据库
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.

Total System Global Area  776646656 bytes
Fixed Size            2257272 bytes
Variable Size          507514504 bytes
Database Buffers      260046848 bytes
Redo Buffers            6828032 bytes
Database mounted.
Database opened.

查看更改后的字符集编码
SQL> select userenv('language') from dual;

USERENV('LANGUAGE')
----------------------------------------------------
AMERICAN_AMERICA.AL32UTF8

SQL>

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2026-4-17 19:50 , Processed in 0.223127 second(s), 21 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表