How to view and modify character sets on the Oracle Database Server

Source: Internet
Author: User

Oracle DatabaseView and modify the serverCharacter SetThe method is described in this article. Let's take a look at this part.

A. oracle server Character Set Query

Select userenv ('language') from dual

The NLS_CHARACTERSET is the server-side character set.

NLS_LANGUAGE is the server-side character display form

B. query the character set of the oracle client

$ Echo $ NLS_LANG

If the data you select is garbled, configure the character set of the client to be the same as that of the linux operating system. If garbled characters exist, the data in the database may be faulty, or the configuration of the oracle server may be faulty.

C. server-side character set Modification

Start the database to RESTRICTED mode and make character set changes:

 
 
  1. SQL> conn /as sysdba  
  2. Connected.  
  3. SQL> shutdown immediate;  
  4. Database closed.  
  5. Database dismounted.  
  6. ORACLE instance shut down.  
  7. SQL> startup mount  
  8. ORACLE instance started.  
  9. Total System Global Area 236000356 bytes  
  10. Fixed Size                   451684 bytes  
  11. Variable Size             201326592 bytes  
  12. Database Buffers           33554432 bytes  
  13. Redo Buffers                 667648 bytes  
  14. Database mounted.  
  15. SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;  
  16. System altered.  
  17. SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;  
  18. System altered.  
  19. SQL> ALTER SYSTEM SET AQ_TM_PROCESSES=0;  
  20. System altered.  
  21. SQL> alter database open;  
  22. Database altered.  
  23. SQL> ALTER DATABASE CHARACTER SET ZHS16GBK;  
  24. ALTER DATABASE CHARACTER SET ZHS16GBK  
  25. ERROR at line 1:  
  26. ORA-12712: new character set must be a superset of old character set 

Note: The new character set must be a superset of the old one. In this case, we can skip the superset check and make changes:

 
 
  1. SQL> ALTER DATABASE character set INTERNAL_USE ZHS16GBK;
  2. Database altered.
  3. SQL> select * from v $ nls_parameters;
  4. Omitted
  5. 19 rows selected.

Restart check whether the change is complete:

 
 
  1. SQL> shutdown immediate;
  2. Database closed.
  3. Database dismounted.
  4. ORACLE instance shut down.
  5. SQL> startup
  6. ORACLE instance started.
  7. Total System Global Area 236000356 bytes
  8. Fixed Size 451684 bytes
  9. Variable Size 201326592 bytes
  10. Database Buffers 33554432 bytes
  11. Redo Buffers 667648 bytes
  12. Database mounted.
  13. Database opened.
  14. SQL> select * from v $ nls_parameters;
  15. Omitted
  16. 19 rows selected.

We can see that this process is exactly the same as the internal process of the alter database character set operation. That is to say, the help provided by INTERNAL_USE is that the Oracle DATABASE bypasses the validation of the subset and superset.

This method is useful in some aspects, such as testing. Everyone should be very careful when applied to the product environment. no one except you will be responsible for the consequences.

Conclusion ):

For DBA, there is a very important principle: Do not put your database in danger!

This requires us to back up the database before performing any operations that may change the database structure. Many DBAs do not have backup operations and have learned a lot.

D. client-side character set Modification

In. bash_profile under the/home/oracle and/root User Directories

Add or modify the export NLS_LANG = "AMERICAN_AMERICA.UTF8" Statement

Close the current ssh window.

Note: The NLS_LANG variable must be correctly configured; otherwise, sqlplus will become invalid.

This article introduces how to view and modify character sets on the server in the Oracle database. I hope you will get some benefits!

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.