How to modify the Oracle Character Set

Source: Internet
Author: User

We all know that Oracle character sets are inclusive. For example, us7ascii is a subset of zhs16gbk. There are no problems in data interpretation between us7ascii and zhs16gbk, and no data loss occurs. Utf8 should be the largest among all character sets because it is based on unicode and stores double-byte characters (so it occupies more space ).

Once a database is created, the character set of the database cannot be changed theoretically. Therefore, it is important to consider which character set to use at the beginning of design and installation. According to the official instructions of Oracle, Character Set conversion is from a subset to a superset, but not vice versa. If there is no relation between Subsets and supersets between the two character sets, Oracle Character Set conversion is not supported by Oracle.

For database servers, incorrect Character Set modification may lead to many unpredictable consequences, which may seriously affect the normal operation of the database, therefore, before modification, check whether the two character sets have the relationship between Subsets and supersets. Generally, we do not recommend that you modify the character set of the Oracle database server unless you have.

In particular, the two most common character sets ZHS16GBK and ZHS16CGB231280 do not have a subset or hyper-set relationship. Therefore, in theory, the conversion between these two Oracle character sets is not supported.

Modify the server character set (not recommended)

Before Oracle 8, you can directly modify the data dictionary table props $ to change the Oracle Character Set of the database. However, after Oracle8, at least three system tables record the information of the database character set. modifying only the props $ table is incomplete and may cause serious consequences. The correct modification method is as follows:

 
 
  1. $sqlplus /nolog  
  2. SQL>conn / as sysdba;    

If the database server has been started, run the shutdown immediate command to shut down the database server, and then run the following command:

 
 
  1. SQL>STARTUP MOUNT;  
  2. SQL>ALTER SYSTEM ENABLE RESTRICTED SESSION;  
  3. SQL>ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;  
  4. SQL>ALTER SYSTEM SET AQ_TM_PROCESSES=0;  
  5. SQL>ALTER DATABASE OPEN;  
  6. SQL>ALTER DATABASE CHARACTER SET ZHS16GBK;  
  7. SQL>ALTER DATABASE national CHARACTER SET ZHS16GBK;  
  8. SQL>SHUTDOWN IMMEDIATE;  
  9. SQL>STARTUP  

NOTE: If there are no large objects, there is no impact on language conversion during use. Remember to set the Oracle character set to be supported by Oracle, or you cannot start it, however, a message like 'ora-12717: Cannot alter database national character set when NCLOB data exists' may appear.

There are two ways to solve this problem

One is to use the INTERNAL_USE keyword to modify the region settings,

Another method is to use re-create, but re-create is a little complicated, so use internal_use,

 
 
  1. SQL>SHUTDOWN IMMEDIATE;  
  2. SQL>STARTUP MOUNT EXCLUSIVE;  
  3. SQL>ALTER SYSTEM ENABLE RESTRICTED SESSION;  
  4. SQL>ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;  
  5. SQL>ALTER SYSTEM SET AQ_TM_PROCESSES=0;  
  6. SQL>ALTER DATABASE OPEN;  
  7. SQL>ALTER DATABASE NATIONAL CHARACTER SET INTERNAL_USE UTF8;  
  8. SQL>SHUTDOWN immediate;  
  9. SQL>startup;  

If you follow the above steps, there will be no problem with the region settings of the National charset. The above content is the description of modifying the Oracle character set. I hope it will help you in this regard.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.