查询数据库字符集,将字符集改为ZHS16GBK
SQL> select * from nls_database_parameters where parameter='NLS_CHARACTERSET';
PARAMETER
--------------------------------------------------------------------------------
VALUE
--------------------------------------------------------------------------------
NLS_CHARACTERSET
WE8MSWIN1252
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB_ORCL READ WRITE NO
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB_ORCL READ WRITE NO
关闭数据库
SQL> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
启动数据库到mount模式
SQL> startup mount
ORACLE instance started.
Total System Global Area 1.6267E+11 bytes
Fixed Size 7653480 bytes
Variable Size 2.4159E+10 bytes
Database Buffers 1.3798E+11 bytes
Redo Buffers 529215488 bytes
Database mounted.
限制session并修改相关参数(记住参数值,最后更改完字符集需要将这些参数改成原值)
SQL> alter system enable restricted session;
System altered.
SQL> show parameter job_queue_processes;
NAME TYPE
------------------------------------ ----------------------
VALUE
------------------------------
job_queue_processes integer
1000
SQL> show parameter aq_tm_processes;
NAME TYPE
------------------------------------ ----------------------
VALUE
------------------------------
aq_tm_processes integer
1
SQL> alter system set job_queue_processes=0;
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
出现错误提示,新字符集必须是老字符集的超集,也就原来字符集是新字符集的子集。
使用Oracle内部命令internal_use跳过使用超集检查。
SQL> alter database character set internal_use ZHS16GBK;
alter database character set internal_use ZHS16GBK
*
ERROR at line 1:
ORA-12720: operation requires database is in EXCLUSIVE mode
报错信息要求数据库在EXCLUSIVE模式下,修改集群数据库参数为false(单库不需要调整该参数
,该参数在修改完字符集之后需要改回原值)并重启数据库
SQL> alter system set cluster_database=FALSE scope=spfile sid='*';
System altered.
SQL> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
注意:启动数据库需要启动到restrict模式下,不然在修改字符集的时候可能汇报如下错误:
ORA-12719: operation requires database is in RESTRICTED mode
SQL> startup restrict
ORACLE instance started.
Total System Global Area 1.6267E+11 bytes
Fixed Size 7653480 bytes
Variable Size 2.4159E+10 bytes
Database Buffers 1.3798E+11 bytes
Redo Buffers 529215488 bytes
Database mounted.
Database opened.
SQL> alter database character set internal_use ZHS16GBK;
Database altered.
SQL> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 1.6267E+11 bytes
Fixed Size 7653480 bytes
Variable Size 2.4159E+10 bytes
Database Buffers 1.3798E+11 bytes
Redo Buffers 529215488 bytes
Database mounted.
Database opened.
查询修改结果并将上述修改的参数调整为原来的值。
SQL> select * from nls_database_parameters where parameter='NLS_CHARACTERSET';
PARAMETER
--------------------------------------------------------------------------------
VALUE
--------------------------------------------------------------------------------
NLS_CHARACTERSET
ZHS16GBK
SQL> alter system set cluster_database=TRUE scope=spfile sid='*';
System altered.
SQL> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 1.6267E+11 bytes
Fixed Size 7653480 bytes
Variable Size 2.4159E+10 bytes
Database Buffers 1.3798E+11 bytes
Redo Buffers 529215488 bytes
Database mounted.
SQL> alter system set job_queue_processes=1000;
System altered.
SQL> alter database open;
Database altered.
SQL> show parameter cluster_database
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cluster_database boolean TRUE
cluster_database_instances integer 2
SQL> show parameter job_queue_processes;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
job_queue_processes integer 1000
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 131
Next log sequence to archive 132
Current log sequence 132
SQL> select * from nls_database_parameters where parameter='NLS_CHARACTERSET';
PARAMETER
--------------------------------------------------------------------------------
VALUE
--------------------------------------------------------------------------------
NLS_CHARACTERSET
ZHS16GBK
SQL> select * from nls_database_parameters where parameter='NLS_CHARACTERSET';
PARAMETER
--------------------------------------------------------------------------------
VALUE
--------------------------------------------------------------------------------
NLS_CHARACTERSET
WE8MSWIN1252
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB_ORCL READ WRITE NO
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDB_ORCL READ WRITE NO
关闭数据库
SQL> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
启动数据库到mount模式
SQL> startup mount
ORACLE instance started.
Total System Global Area 1.6267E+11 bytes
Fixed Size 7653480 bytes
Variable Size 2.4159E+10 bytes
Database Buffers 1.3798E+11 bytes
Redo Buffers 529215488 bytes
Database mounted.
限制session并修改相关参数(记住参数值,最后更改完字符集需要将这些参数改成原值)
SQL> alter system enable restricted session;
System altered.
SQL> show parameter job_queue_processes;
NAME TYPE
------------------------------------ ----------------------
VALUE
------------------------------
job_queue_processes integer
1000
SQL> show parameter aq_tm_processes;
NAME TYPE
------------------------------------ ----------------------
VALUE
------------------------------
aq_tm_processes integer
1
SQL> alter system set job_queue_processes=0;
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
出现错误提示,新字符集必须是老字符集的超集,也就原来字符集是新字符集的子集。
使用Oracle内部命令internal_use跳过使用超集检查。
SQL> alter database character set internal_use ZHS16GBK;
alter database character set internal_use ZHS16GBK
*
ERROR at line 1:
ORA-12720: operation requires database is in EXCLUSIVE mode
报错信息要求数据库在EXCLUSIVE模式下,修改集群数据库参数为false(单库不需要调整该参数
,该参数在修改完字符集之后需要改回原值)并重启数据库
SQL> alter system set cluster_database=FALSE scope=spfile sid='*';
System altered.
SQL> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
注意:启动数据库需要启动到restrict模式下,不然在修改字符集的时候可能汇报如下错误:
ORA-12719: operation requires database is in RESTRICTED mode
SQL> startup restrict
ORACLE instance started.
Total System Global Area 1.6267E+11 bytes
Fixed Size 7653480 bytes
Variable Size 2.4159E+10 bytes
Database Buffers 1.3798E+11 bytes
Redo Buffers 529215488 bytes
Database mounted.
Database opened.
SQL> alter database character set internal_use ZHS16GBK;
Database altered.
SQL> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 1.6267E+11 bytes
Fixed Size 7653480 bytes
Variable Size 2.4159E+10 bytes
Database Buffers 1.3798E+11 bytes
Redo Buffers 529215488 bytes
Database mounted.
Database opened.
查询修改结果并将上述修改的参数调整为原来的值。
SQL> select * from nls_database_parameters where parameter='NLS_CHARACTERSET';
PARAMETER
--------------------------------------------------------------------------------
VALUE
--------------------------------------------------------------------------------
NLS_CHARACTERSET
ZHS16GBK
SQL> alter system set cluster_database=TRUE scope=spfile sid='*';
System altered.
SQL> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 1.6267E+11 bytes
Fixed Size 7653480 bytes
Variable Size 2.4159E+10 bytes
Database Buffers 1.3798E+11 bytes
Redo Buffers 529215488 bytes
Database mounted.
SQL> alter system set job_queue_processes=1000;
System altered.
SQL> alter database open;
Database altered.
SQL> show parameter cluster_database
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
cluster_database boolean TRUE
cluster_database_instances integer 2
SQL> show parameter job_queue_processes;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
job_queue_processes integer 1000
SQL> archive log list
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 131
Next log sequence to archive 132
Current log sequence 132
SQL> select * from nls_database_parameters where parameter='NLS_CHARACTERSET';
PARAMETER
--------------------------------------------------------------------------------
VALUE
--------------------------------------------------------------------------------
NLS_CHARACTERSET
ZHS16GBK
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31403259/viewspace-2126649/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/31403259/viewspace-2126649/