Oracle Length 和 Lengthb 函数说明 .(用来判断记录值里是否有中文内容)
一.官网的说明
http://download.oracle.com/docs/cd/E11882_01/server.112/e26088/functions088.htm#SQLRF00658
Purpose
The LENGTH functionsreturn the length of char. LENGTH calculates length usingcharacters as defined by the input character set.
--返回以字符为单位的长度.
LENGTHB usesbytes instead of characters.
--返回以字节为单位的长度.
LENGTHC usesUnicode complete characters.
--返回以Unicode完全字符为单位的长度.
LENGTH2 usesUCS2 code points.
--返回以UCS2代码点为单位的长度.
LENGTH4 usesUCS4 code points.
--返回以UCS4代码点为单位的长度.
char can beany of the data types char, varchar2, nchar, nvarchar2, clob,or nclob.
The exceptionsare LENGTHC, LENGTH2, and LENGTH4, which do not allow char tobe a CLOB or NCLOB. The return value is of data type NUMBER.If char has data type CHAR, then the length includes all trailingblanks. If char is null, then this function returns null.
Restriction on LENGTHB (Lengthb函数的限制)
The LENGTHB functionis supported for single-byte LOBs only. It cannot be used with CLOB and NCLOB datain a multibyte character set.
Examples
The followingexample uses the LENGTH function using a single-byte databasecharacter set:
SELECT LENGTH('CANDIDE') "Length incharacters" FROM DUAL;
Length in characters
--------------------
7
The next example assumes a double-bytedatabase character set.
SELECT LENGTHB ('CANDIDE') "Length inbytes" FROM DUAL;
Length in bytes
---------------
14
二.示例说明
在不同的数据库,因为字符集的不同,LENGTHB得到的值可能会不一样。如ZHS16GBK采用两个byte位来定义一个汉字。而在UTF8,采用3个byte。
SYS@anqing1(rac1)> SELECT USERENV('LANGUAGE') FROM DUAL;
USERENV('LANGUAGE')
----------------------------------------------------
AMERICAN_AMERICA.ZHS16GBK
SQL>select length('安庆') from dual;
2
SQL>select lengthb('安庆') from dual;
4
SQL>select length('AnQing') from dual;
6
SQL>select lengthb('AnQing') from dual;
6
通过这个示例,我们可以看出来,Length 和 Lengthb 函数的一个重要用处,就是用来判断记录值里是否有中文内容。
如果有中文,那么Length() != Lengthb()
如果没有中文,那么Length() == Lengthb()
转载于:https://www.cnblogs.com/toSeeMyDream/p/4741695.html
Oracle Length 和 Lengthb 函数说明 .(用来判断记录值里是否有中文内容)相关推荐
- oracle length函数中文,Oracle Length 和 Lengthb 函数说明 .(用来判断记录值里是否有中文内容)...
一.官网的说明 Purpose The LENGTH functionsreturn the length of char. LENGTH calculates length usingcharact ...
- oracle消除重复的行使用的什么函数,利用Oracle的row_number() over函数消除重复的记录...
2.select d.id,d.outer_code,row_number() over(partition by outer_code order by outer_code) row_flag f ...
- oracle 修改字段长度_Oracle字段长度引起的思考length()和lengthb()
"小X,问个问题啊,我这里想往一个表里插入另一张表的值.都是vachar2()字段,用length()看,原表那些值的长度都在20以下,目标表是varchar2(22),怎么会报错插入失败, ...
- lengthb 函数和 length 函数
lengthb 函数和 length 函数 lengthb函数计算字节数,length函数记录字符数首先查看数据库的字符集: select * from nls_database_parameters ...
- sql 函数length() 和lengthb()的区别
select length('hello world!') from dual; --12 select length('你好,世界!') from dual; --6 select length(' ...
- oracle lengthb(),Oracle中 length 和 lengthb 区别
Oracle中length和lengthb的区别介绍: SQL> select length('51博客') from dual; LENGTH('51博客') ---------------- ...
- Oracle数据库之单行函数
oracle安装参照: Oracle数据库之安装教程 Oracel数据库总结: Oracle数据库之基本查询 Oracle数据库之单行函数 Oracle数据库之多行函数 Oracle数据库之多表查询 ...
- Oracle中常用的函数——字符类型函数
一.字符函数 1. UPPER(str): 将字符串str中的所有字母转换为大写; 例: SELECT EMPLOYEE_ID , FIRST_NAME , UPPER(FIRST_NAME) ...
- Oracle内置SQL函数-分类整理大全
转载自:http://www.cnblogs.com/yening10000/archive/2009/07/02/1515284.html F.1字符函数--返回字符值 这些函数全都接收的是字符族类 ...
最新文章
- find 命令_Linux下查找文件:find 命令
- GNS3中不同型号路由器支持的模块表
- [Python设计模式] 第17章 程序中的翻译官——适配器模式
- 为Ubuntu Server 安装图形桌面环境
- spring生命周期七个过程_Spring杂文(三)Spring循环引用
- python软件如何安装方法_【新手必看】Python软件下载及安装教程
- jQuery滚动监听插件Waypoints
- Slowquery图形化显示MySQL慢日志工具搭建
- mysql 文章内容_假设mysql数据库里面有个字段存的是文章内容,用什么方式查询出所有文章中包含某个特定词语的数据。...
- python中set index_Python set_index和reset_index详解
- AcWing1081.度的数量(数位DP)题解
- mysql字符串替换_MySQL的字符串替换更新操作
- matlab力学大作业答案,计算力学大作业报告.docx
- 数据链路层的主要功能
- php中怎么获取提交时间,php – 通过curl_getinfo()获取详细信息来获取cURL请求的时间...
- CSGO社区服搭建记录
- Python对Excel的常规操作 之 读取带密码的文件,解除Sheet密码
- ERP的灵魂是管理思想
- android刷机知识大全,安卓主流机型刷机基础科普 教你刷机不求人
- 工业生产中的“主动刹车”,是怎么实现的?