Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deal with Chinese character set garbled in database

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to deal with the garbled Chinese character set in the database". Interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Now let the editor to take you to learn "how to deal with database Chinese character set garbled" it!

I. description of the problem

Colleagues said that the Chinese character set of the test library is garbled and needs to be dealt with.

II. Analysis and treatment

The most important parameter that affects the character set of the oracle database is the NLS_LANG parameter. Its format is as follows:

NLS_LANG = language_territory.charset

It has three components (language, region, and character set), each of which controls the characteristics of the NLS subset. Where:

Language specifies the language of the server message

Territory specifies the date and number format of the server

Charset specifies the character set.

For example, AMERICAN _ AMERICA. ZHS16GBK

SQL > select userenv ('language') from dual;USERENV (' LANGUAGE')-AMERICAN_AMERICA.WE8MSWIN1252

After querying the information on the Internet: reference: https://blog.csdn.net/DBDoctor/article/details/51909047

The database is placed under restricted mode to prevent the database from having new connections with non-dba permissions

SQL > alter system enable restricted session;System altered.

Modify character set to ZHS16GBK

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

Tip: the new character set must be a superset of the old character set, and you can skip checking the superset and make changes:

SQL > ALTER DATABASE character set INTERNAL_USE ZHS16GBK; ALTER DATABASE character set INTERNAL_USE ZHS16GBKERROR at line 1:ORA-12721: operation cannot execute when other sessions are active

Currently, a connection is in active state, kill session or restart the database.

SQL > shutdown immediate;SQL > startup mount;SQL > alter system enable restricted session;System altered.SQL > alter database open;Database altered.SQL > ALTER DATABASE character set INTERNAL_USE ZHS16GBK; Database altered.SQL > alter system disable restricted session;System altered.SQL > select userenv ('language') from dual USERENV ('LANGUAGE')-AMERICAN_AMERICA.ZHS16GBK here, I believe you have a deeper understanding of "how to deal with database Chinese character set garbled", might as well to actual operation it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report