日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

LTRIM、RTRIM和TRIM在ORACLE中的用法:

發布時間:2025/3/20 编程问答 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 LTRIM、RTRIM和TRIM在ORACLE中的用法: 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

? LTRIM、RTRIM和TRIM在ORACLE中的用法:
1、LTRIM(C1,C2)
其中C1和C2都可以字符串,例如C1是'Miss Liu',C2'MisL'等等。這是第一個和SQL SERVER不一樣的地方。如果記得不錯的話SQL Server的LTRIM只有一個參數,作用是去掉字符串左面的空格。而Oracle的LTRIM則是保證C1的第一個字符不能出現在C2字符串中。
?
SQL> select LTRIM( 'Miss Liu', 'Liu') Result? from dual;

RESULT
--------
Miss Liu

?

SQL> select LTRIM( 'Miss Liu', 'M is') result from dual;

RES
---
Liu

?

從上述就可以看出LTRIM的作用。但是如果第二個字符串不進行輸入,那么LTRIM的作用和SQL SERVER中就相同,就是去掉左面的空格。

?

SQL> select ltrim( '? Miss Liu? ' ) result from dual;

RESULT
----------
Miss Liu

SQL> select length( '? Miss Liu? ' ) len1, length( ltrim( '? Miss Liu? ' ) ) lentrim from dual;

????? LEN1??? LENTRIM
---------- ----------
??????? 12???????? 10

由上述可以看出Oracle的LTrim的功能應該更強大一些,能夠對前導符進行操作。

2、RTRIM的功用和LTRIM相同,但是RTRIM修改成了從右向左的,這樣子就是去掉后導符中的特定字符。

3、TRIM的功能如下描述:
?

In Oracle/PLSQL, the trim function removes all specified characters either from the beginning or the ending of a string.

The syntax for the trim function is:

trim( [ leading | trailing | both? [ trim_character ]? ]?? string1 )

leading - remove trim_string from the front of string1.

trailing - remove trim_string from the end of string1.

both - remove trim_string from the front and end of string1.

If none of these are chosen (ie: leading, trailing, both), the trim function will remove trim_string from both the front and end of string1.

?

trim_character is the character that will be removed from string1. If this parameter is omitted, the trim function will remove all leading and trailing spaces from string1.

string1 is the string to trim.

trim('?? tech?? ') would return 'tech'?
trim(' '? from? '?? tech?? ') would return 'tech'?
trim(leading '0' from '000123') would return '123'?
trim(trailing '1' from 'Tech1') would return 'Tech'?
trim(both '1' from '123Tech111') would return '23Tech
?

上面的這些都已經被驗證了,其中leading trailing和Both后面的From不可省略

總結

以上是生活随笔為你收集整理的LTRIM、RTRIM和TRIM在ORACLE中的用法:的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。