Orcale修改数据库字符集

https://www.cnblogs.com/rusking/p/4531444.html

参考这篇文档。

 

首先一定要用sysdba登陆,一个赋予sysdba权限的账号是不行的。

然后一定要用SQL PLUS操作

conn / as sysdba

SHUTDOWN IMMEDIATE; 
STARTUP MOUNT EXCLUSIVE; 
ALTER SYSTEM ENABLE RESTRICTED SESSION;
ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
ALTER SYSTEM SET AQ_TM_PROCESSES=0;
ALTER DATABASE OPEN;
ALTER DATABASE NATIONAL CHARACTER SET AL16UTF16; 更改国际字符集
ALTER DATABASE CHARACTER SET ZHS16GBK; 更改本地字符集
SHUTDOWN IMMEDIATE;
STARTUP ;
 
2.如果错误信息,请对照一下信息
如果提示:
    ORA-12717: Cannot issue ALTER DATABASE NATIONAL CHARACTER SET when NCLOB, NCHAR
or NVARCHAR2 data exists
则更改使用以下语句:
    ALTER DATABASE NATIONAL CHARACTER SET INTERNAL_USE AL16UTF16;
 
如果提示:
    ORA-12712: new character set must be a superset of old character set
则更改使用以下语句:
    ALTER DATABASE character set INTERNAL_USE ZHS16GBK;
如果提示:
    ORA-01109: database not open
则更改使用以下语句:
    ALTER DATABASE OPEN;
 
如果提示:
    ORA-12719: operation requires database is in RESTRICTED mode
则更改使用以下语句:
    ALTER SYSTEM ENABLE RESTRICTED SESSION;
 
如果提示:
    ORA-12721: operation cannot execute when other sessions are active
则更改使用以下语句:
    SHUTDOWN IMMEDIATE; 
    STARTUP MOUNT EXCLUSIVE;
如果还是提示同样的错误,则:

select sid,serial#,username,machine from v$session;查看有哪些SESSION,然后

alter system kill session 'sid'serial#' immediate;

alter system kill session '158,7' immediate;

 
 
 
验证修改是否成功
select value$ from sys.props$ where name='nls_characterset'
修改成功后,取消受限模式
alter system disable restricted session;

posted on 2020-07-14 09:10  格物致知2019  阅读(544)  评论(0编辑  收藏  举报

导航