欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

oracle 10g修改字符集编码 博客分类: 数据库  

程序员文章站 2024-03-23 23:50:52
...

1.       关闭数据库

SQL>SHUTDOWN IMMEDIATE

 

2. 启动到Mount

SQL>STARTUP MOUNT;

SQL>ALTER SYSTEM ENABLE RESTRICTED SESSION;

SQL>ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;

SQL>ALTER SYSTEM SET AQ_TM_PROCESSES=0;

SQL>ALTER DATABASE OPEN;

 

--这里可以从父集到子集

SQL>ALTER DATABASE CHARACTER SET ZHS16GBK;

SQL>ALTER DATABASE NATIONAL CHARACTER SET AL16UTF16;


--如果是从子集到父集,需要使用INTERNAL_USE 参数,跳过超子集检测

SQL>ALTER DATABASE CHARACTER SET INTERNAL_USE AL32UTF8;

SQL>ALTER DATABASE NATIONAL CHARACTER SET INTERNAL_USE AL16UTF16;

 


SQL>SHUTDOWN IMMEDIATE;

SQL>STARTUP

 

 

更改步骤:1、用sysdba角色用户登录sqlplus: 命令行输入:sqlplus sys as sysdba

               2、输入口令,进入sqlplus:sql>---

               3、依次键入下面的命令行执行:

                    shutdown immediate;
                    STARTUP MOUNT;
                    ALTER SESSION SET SQL_TRACE=TRUE;
                    ALTER SYSTEM ENABLE RESTRICTED SESSION;
                    ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
                    ALTER SYSTEM SET AQ_TM_PROCESSES=0;
                    ALTER DATABASE OPEN;
                    ALTER DATABASE character set INTERNAL_USE AL32UTF8;
                    ALTER SESSION SET SQL_TRACE=FALSE;
                    shutdown immediate;
                    startup;

风险分析:执行上述命令,有可能造成数据库中已有数据混乱的情况,所以在进行操作前,

               要进行数据库的备份操作;

结果查看:察看 NLS_LANG 信息:
               SELECT parameter, value FROM v$nls_parameters WHERE parameter LIKE '%CHARACTERSET';
              NLS_LANG 信息已经变成:


              NLS_CHARACTERSET
              AL32UTF8
              NLS_NCHAR_CHARACTERSET
              AL16UTF16