oracle中字符串比较的问题 [英] Questions of string comparison in oracle

查看:83
本文介绍了oracle中字符串比较的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读oracle的基础知识,并遇到了奇怪的陈述.我不知道这是真的.

I am reading basics of oracle and came across strange statement. I don't know how much true it is.

声明说

字符串值'2'大于字符串值'100'. "1"小于字符"10". "

" String value '2' is greater than String value '100'. Character '1' is less than Character '10'. "

请就上述主题进行一些说明.我了解必须使用ASCII值进行内部比较.我正在寻求一些合理的解释.

Kindly throw some light on above topic. I understand that internally comparison must be happening using ASCII values. I am seeking some good logical explanation.

推荐答案

这意味着被视为字符串的数字不是按照数字顺序排序,而是按照词汇顺序排序,字典中单词的排序方式相同.也就是说,每次从左侧比较一个字符.

It means that numbers treated as strings are not sorted in numerical order but in lexical order, the same way words are sorted in a dictionary. That is, characters are compared one at a time from the left side.

在您的第一个示例中,"2"大于"100",因为将"2"与"1"进行比较并发现更大.将此与字典中"C"和"BAA"的顺序进行比较.

In your first example, "2" is greater than "100" because the '2' is compared to the '1' and found to be bigger. Compare this to the ordering of "C" and "BAA" in a dictionary.

在第二个示例中,"1"小于"10",因为"1"与"10"左侧的"1"完全匹配,但是"10"在匹配之后有字符.因此,它更大.再次,将其与字典中"B"和"BA"的顺序进行比较.

In your second example, "1" is less than "10" because the "1" fully matches the "1" in the left side of "10", but the "10" has characters following the match. Therefore it is greater. Again, compare this to the ordering of "B" and "BA" in a dictionary.

这篇关于oracle中字符串比较的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆