本文介绍了如何在Oracle Varchar2中存储字节,并将ASCII视为文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在Varchar2中存储字节,例如,当它是ASCII时,它是否被正常处理为文本? (如在查询中)。

How can I have bytes stored in a Varchar2, and have it treated "normally" as text when it is ASCII for example? (Like in queries).

如果不可能,限制在哪里?

If not possible, where is the limitation?

用字符集定义,所以如果它是ANSI例如,什么样的1字节值可以不放在那里?对于1字节字符集,有比ANSI更好的解决方案吗?

I know the column is defined with a character sets, so if it is ANSI for example, what kind of 1-byte values can I not put there? Are there "better" solutions than ANSI for 1-byte character sets?

推荐答案

您必须将字节编码为文本。您可以使用 rawtohex 函数或 utl_encode 包。为了显示字符,你必须使用反函数,然后将原始字节转换为varchar2。使用 utl_raw.cast_to_varchar2

You have to encode bytes into text. You can use rawtohex function or utl_encode package. For displaying characters you have to use inverse function and then convert raw bytes to varchar2. Use utl_raw.cast_to_varchar2.

这篇关于如何在Oracle Varchar2中存储字节,并将ASCII视为文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 00:24