Oracle filter 函数,Oracle数据库之SQL单行函数---字符函数续
前一篇博客練習了一些字符函數,之后自己又去下查閱了相關的資料,上一篇博客中還有很多的
字符函數沒有練習到,這次主要是對上次的一些未用到的字符函數進行一些補充練習。
ascii()
返回與指定的字符對應的十進制數,若為字符串則返回字符串首字母的十進制數。select ascii('AAA') A,ascii('aa') a,ascii('0') ZERO , ascii(' ') space from dual;
chr()
與ascii函數相反,給出整數返回特定的字符select chr(65) x,chr(97) y from dual;
instr(C1,C2,I,J)
在一個字符串中搜索指定的字符,返回指定額字符的位置,只檢索一次
C1:被搜索的字符串
C2:希望搜索的字符串
I:搜索的開始位置,默認為1,若果為正,從左到右開始檢索,反之。為0不檢索
J:出現的位置:tips:這個位置指的是第幾次出現。默認為1,為負或0則系統報錯,
例子:select instr('Oracle hello Oracle hello','Oracle',-1,2) from dual;
ltrim、rtrim
select RTRIM('hello oracle','oracle') from dual;--結果為hello:刪除右邊的‘oracle’
soundex
很有意思的一個函數返回一個與給定字符串讀音相同的字符串
create table test_soundex ( username varchar2(20) ); insert into test_soundex values('Kiritor'); insert into test_soundex values('Kirito'); insert into test_soundex values('kiritor'); insert into test_soundex values('Alex'); select username from test_soundex where soundex(username)=soundex('Kiritor');
???????????
字符串處理函數中有一個TRIM函數筆者會找個時間詳細的理解、練習。
總結
以上是生活随笔為你收集整理的Oracle filter 函数,Oracle数据库之SQL单行函数---字符函数续的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 自 2007 年史蒂夫・乔布斯宣布初代
- 下一篇: 1 月 20 日开播,苹果 Apple