Oracle中查询条件
来源:互联网 发布:动态截图软件 编辑:程序博客网 时间:2024/05/18 00:45
* 在姓名表中查询:
1 . 姓陈
2 . 姓名是三个字的姓名
3 . 性别为女
4 . 在2000年后出生
select count((t.last_name || t.first_name)) as countNumber,(t.last_name || t.first_name) as vipName,t.gender
from name_info_t t
where ((length(last_name) + length(first_name)) > 2 and
(length(last_name) + length(first_name)) < 4 and
t.birthday > to_date('2000-01-01', 'yyyy-MM-dd') and
t.last_name like '%陈%' and t.gender <> '1')--0:女 1:男
group by (t.last_name || t.first_name), t.gender;
* lengthb(string)计算string所占的字节长度:返回字符串的长度,单位是字节
length(string)计算string所占的字符长度:返回字符串的长度,单位是字符
用length('string')=lengthb('string')判断字符串是否含有中文。
对于单字节字符,LENGTHB和LENGTH是一样的。
一个汉字在Oracle数据库里占多少字节跟数据库的字符集有关,UTF8时,长度为三。
select lengthb('飘') from dual;
select length('飘') from dual;
可查询汉字在Oracle数据库里占多少字节
* length(123)=3,是计算123的长度length('abc')=3,是计算'abc'的长度length(123abc)和length(abc)中,函数将其当做是变量,因为它既不是有效的数字,也不是有效的字符串(如'asdf',带引号的),所以就会出现"标识符无效"等错误。
* The "length" functions return the length of char. LENGTH calculates length using characters as defined by the input character set.
LENGTHB uses bytes instead of characters. LENGTHC uses Unicode complete characters. LENGTH2 uses UCS2 codepoints. LENGTH4 uses UCS4 codepoints
length函数返回字符的长度,它使用定义好的输入的字符集计算长度.
lengthb使用bytes代替字符
VSIZE returns the number of bytes in the internal representation of expr.
vsize 返回内部表示的字节的数目。
select length('asdfg测试') bytesLengthIs from dual ;
--7
select lengthb('asdfg') bytesLengthIs from dual ;
select vsize('asdfg') bytesLengthIs from dual ;
--5
select lengthb('asdfg测试') bytesLengthIs from dual ;
select vsize('asdfg测试') bytesLengthIs from dual ;
--11
select lengthc('asdfg测试') bytesLengthIs from dual ;
--7
则在utf-8的字符集下
lengthb=vsize
lengthc=length
参考文献:Oracle9i SQL Reference Release 2 (9.2)
希望对你有帮助,祝你有一个好心情,加油!
若有错误、不全、可优化的点,欢迎纠正与补充!
- Oracle中查询条件
- Oracle中不同条件的日期查询
- oracle中无法查询中文条件
- Oracle中不同条件的日期查询
- oracle中无法查询中文条件
- 关于oracle中无法查询中文条件的解决方法
- oracle 中sql的查询条件有NULL的处理
- oracle left join 查询on中出现and条件
- Oracle SQL 条件查询语句
- oracle 可选模糊条件查询
- SQL ORACLE 查询 日期条件
- oracle 时间差 做查询条件
- oracle 递归查询 + 条件 + 排序
- Oracle连接查询条件分析
- oracle where条件分支查询
- oracle 中如何在使用sum或其他聚合函数中,select查询条件处如何使用判断条件
- Oracle中实现查询结果按照in中条件排序 InStr函数
- (笔记)VB中修改字体大小、日期加减,oracle数据库中查询条件为日期类型
- 数据库查询
- 安卓实现滚动选择器
- 史上最简单的 MySQL 教程(十三)「列属性 之 空属性、列描述和默认值」
- MIPI转RGB芯片ICN6211规格书详细内容
- Kotlin:Android世界的Swift
- Oracle中查询条件
- 进程间通信之信号量(三)
- Webrtc delay-base-bwe代码分析(1): RateStatistics模块
- 二叉树线索化
- 数据库增删改练习
- 图解NIO(1) Buffer 与 Channel
- opencv(24)---轮廓特征属性及应用之最小外接圆
- 《lua程序设计》读书笔记 第二章:类型与值
- 关于select2默认选中 动态选中 显示,刷新选中