当前位置:网站首页>Usage of trim, ltrim and rtrim functions of Oracle
Usage of trim, ltrim and rtrim functions of Oracle
2022-06-22 06:16:00 【La la la~~~~~】
Basic usage :
- Remove spaces before and after the specified string
select trim(' hello caicai ')trim from dual;-- When no alias is added , There is still a space to the right of the display string .
2. Remove the space around the specified string
select ltrim(' hello caicai ')ltrim from dual;-- Left
![]()
select rtrim(' hello caicai ')rtrim from dual;-- Right
![]()
Advanced usage :
Receive other parameters to remove the left of the specified string 、 Characters on the right and both sides .
The advanced usage here can not only remove half width spaces , You can also remove all blank spaces , And basic trim Usage: only half width spaces can be removed .
- The case where the interception set is one character ( Be careful : The intercept set here can only be one character , Otherwise, the report will be wrong )
select trim(leading ' ' from ' hello caicai ') leadingtrim from dual;
![]()
select trim(trailing ' ' from ' hello caicai ') trailingtrim from dual;
![]()
select trim(both ' ' from ' hello caicai ') bothtrim from dual;
![]()
select trim(leading 'y' from 'ya hello caicai y') leadingtrim from dual;
![]()
select trim(trailing 'y' from 'ya hello caicai y') trailingtrim from dual;
![]()
select trim(both 'y' from 'ya hello caicai y') bothtrim from dual;
![]()
No keywords leading,trailing,both, Its usage is equivalent to trim Basic usage .
select trim( 'y' from 'ya hello caicai y') leadingtrim from dual;
![]()
2. When the interception set is multiple characters :
ltrim(string1,string2),rtrim(string1,string2)
ltrim(string1,string2): From a string string1 The left side starts to remove and string2 A character that matches a single character in a character set , Until string1 Encountered a character in , The character is not in string2 In the character set .
In a nutshell , take string2 Each character in the is associated with string1 Each character starting on the left matches , If the same , Then continue to match , If it is different, return its characters and the remaining characters .
select ltrim('abcbcaxcba','abc') ltrim from dual;
![]()
rtrim(string1,string2): From a string string1 The right side starts to remove and string2 A character that matches a single character in a character set , Until string1 Encountered a character in , The character is not in string2 In the character set .
In a nutshell , take string2 Each character in the is associated with string1 Each character starting on the right matches , If the same , Then continue to match , If it is different, return its characters and the remaining characters .
select rtrim('abcbcaxcba','abc') rtrim from dual;
![]()
Be careful :
In the use of trim,ltrim,rtrim Advanced use of , The blank space corresponds to Airbus , Empty string corresponds to empty string , Otherwise, you will not get the results you want . Note spaces and empty strings , Space refers to a space in quotation marks , An empty string means that there is nothing between the quotation marks .
Such as :
Space Empty string
SELECT ltrim(' abcbcaxcba','') rtrim FROM dual;
![]()
Space Space
SELECT ltrim(' abcbcaxcba',' ') rtrim FROM dual;
![]()
If you are interested in this knowledge , Clickable Link for details .
边栏推荐
- C#中的数组及Foreach遍历
- CGIC文件上传----菜鸟笔记
- IO密集型和CPU密集型
- e. Hash & oldcap = = 0 detailed interpretation
- 生信可视化(part2)--箱线图
- PIR控制器调节器并网逆变器电流谐波抑制策略
- Single cell thesis record (Part12) -- unsupervised spatial embedded deep representation of spatial transcriptomics
- Improve your game‘s performance
- 单细胞论文记录(part12)--Unsupervised Spatial Embedded Deep Representation of Spatial Transcriptomics
- 小熊派BearPi-HM Micro正式合入OpenHarmony主干
猜你喜欢
随机推荐
相干声呐GeoSwath的综述
MiniGUl 1.1.0版本引入的新GDI功能和函数(二)
Bathymetry along Jamaica coast based on Satellite Sounding
Case analysis of terminal data leakage prevention
SQL 注入漏洞(十一)宽字节注入
Bat common batch script record
878. 第 N 个神奇数字 数学+二分
leetcode每周3道(八)图之最短路
反射操作注解
3D asset optimization and vertex data management for performance optimization
Lock锁(重点)
matlab 的离散pid控制
simulink中搭建专家pid控制
You are using PIP version 19.0.3, however version 22.1.2 is available
R语言观察日志(part24)--writexl包
Unity development - scene asynchronous loading
信息系统项目管理 - 范围管理(划重点)
单细胞论文记录(part13)--SpaGCN: Integrating gene expression, spatial location and histology to ...
SSM整合所需配置文件及常见配置错误引起的报错
R language observation log (part24) -- writexl package
![[technical notes]](/img/5c/3a1fa6326f0bf16da8032526173343.png)








