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

Knowledge collation of oracle characters and bytes

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

This article mainly explains the "knowledge collation of oracle characters and bytes". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "the knowledge arrangement of oracle characters and bytes".

Terminology:

Bit: the smallest unit of data stored inside a computer, and 11001100 is an eight-digit binary number.

Byte: the basic unit of data processing in a computer, conventionally expressed in uppercase B, 1B (byte) = 8bit (bit)

Characters: letters, numbers, words, and symbols used in a computer

Description:

In oracle, NVARCHAR2 and NCHAR use the National character set (NLS_NCHAR_CHARACTERSET), which must be

One of AL16UTF16 or UTF8; the other character types use the standard character set (NLS_CHARACTERSET). For example, the character set query of this library is as follows:

test

(1) first, test the database character set as ZHS16GBK and the national character set as UTF8:

Create a test table and insert data:

Create table t_var (va nvarchar2 (32), vb varchar2 (32))

Insert into t_var values ('Hello', 'Hello')

Insert into t_var values ('hello','hello')

At this point, we inquire:

Test results:

a. When the character type uses the standard character set of ZHS16GBK, one English character occupies one byte and one Chinese character occupies two bytes.

b. When the character type uses the national character set of UTF8, one English character occupies one byte and one Chinese character occupies three bytes.

(2) then we do the same test above when the standard character set of another library is ZHS16GBK and the national character set is AL16UTF16:

Test results:

a. When the character type uses the standard character set of ZHS16GBK, one English character occupies one byte and one Chinese character occupies two bytes.

b. When the character type uses the national character set of AL16UTF16, one English character occupies two bytes and one Chinese character occupies two bytes.

The above is a simple test process, which shows that when we choose different character types, a character occupies different bytes, which may have an impact on the use of some character-handling functions.

In addition, in our daily work, we may have seen the following definition of character length:

Varchar2 (32)

Varchar2 (32 char)

Varchar2 (32 byte)

All three definitions are correct, except that they mean different things:

Varchar2 (32 char): specifies that the maximum string length is 32 bits, whether in Chinese or English, and the maximum storage length is 32 bits

Varchar2 (32 byte): specifies that the maximum number of bytes occupied by a string is 32, for example, a maximum of 16 bytes in Chinese and 32 in English are allowed to be stored.

Varchar2 (32): the measure of the maximum length of a string that is not clearly specified is based on byte or char.

Parameter NLS_LENGTH_SEMANTICS

Query the parameter in the test library as follows:

You can see that the default measure of string length for the database is BYTE.

Thank you for your reading, the above is the content of "knowledge collation of oracle characters and bytes". After the study of this article, I believe you have a deeper understanding of the knowledge arrangement of oracle characters and bytes, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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