oracle學習(三) 常用字元處處理函式

2021-07-12 06:23:37 字數 1359 閱讀 2502

--左填充

select "lpad"('12345', 6, 0) from dual;-->012345

select "lpad"('12345', 3, 0) from dual;-->123

--右填充

select "rpad"('12345', 6, 0) from dual;-->123450

select "rpad"('12345', 3, 0) from dual;-->123

--小寫

select "lower"('abcd') from dual;-->abcd

--大寫

select "upper"('abcd') from dual;-->abcd

--標題格式

select "initcap"('abcd') from dual;-->abcd

--長度

select "length"('123456') from dual;-->6

select "length"('就是我') from dual;-->3

--從第二位開始取3個字元

select "substr"('123456', 2, 3) from dual;-->234

--查詢位置

select "instr"('12345678945', '45') from dual;-->4

--從7開始查詢45第一次出現的位置

select "instr"('12345678945', '45',7) from dual;-->10

--從7開始查詢45第三次出現的位置

select "instr"('12345678945', '45',7,3) from dual;-->0

--去左空格

select "ltrim"('     000     ') from dual;-->000     

--去右空格

select "rtrim"('     000     ') from dual;-->000

--去空格

select "trim"('     000     ') from dual;-->000

--連線

select "concat"('hello', 'world') from dual;-->helloworld

--查詢

select "translate"('abcd', 'a--b--c--d', '123456790abcdefg') from dual;-->147a

-- 替換

select "translate"('1d2b3a4d5egad4', '#abcdefghigklmnopqrstuvwxyz', ' ') from dual;-->123454

ORACLE 常用字元函式

1.lower lower str 強制小寫 2.upper upper str 強制大寫 3.initcap initcap str 每個單詞首字母大寫 示例 sql select initcap my boy from dual 返回 my boy 注意 單詞之間用下劃線 分割 4.concat...

python常用字串 Python常用字串操作

1.字串首字母大寫 2.統計字串中某個字母的個數 統計字串中某個字母的個數又分兩種情況,在整個字串中統計和在某個索引範圍內統計 1 在整個字串中統計,如下面統計字串str2中字母a的個數 2 在某個索引區間內統計,如下面統計字串str2索引1到10和1到30範圍內字母t的個數 3.求字串的長度 4....

Oracle 常用字元函式之Translate

oracle 常用字元函式之translate,返回將出現在from中的每個字元替換為to中相應字元,若from比to字串長,那麼在from中比to多出 語法 translate char,from,to 用法 返回將出現在from中的每個字元替換為to中相應字元,若from比to字串長,那麼在fr...