動態規劃之理論分析
阿新 • • 發佈:2021-08-15
用法:
select parse_url("",[HOST,PATH,QUERY,REF,PROTOCOL,FILE,AUTHORITY,USERINFO])
舉例 :
select parse_url('http://facebook.com/path/p1.php?query=1', 'PROTOCOL') from dual;
---http
select parse_url('http://facebook.com/path/p1.php?query=1', 'HOST') from dual;
---facebook.com
select parse_url('http://facebook.com/path/p1.php?query=1', 'REF') from dual;
---空
select parse_url('http://facebook.com/path/p1.php?query=1', 'PATH') from dual;
---/path/p1.php
select parse_url('http://facebook.com/path/p1.php?query=1', 'QUERY')from dual;
---空
select parse_url('http://facebook.com/path/p1.php?query=1', 'FILE') from dual;
---/path/p1.php?query=1
select parse_url('http://facebook.com/path/p1.php?query=1', 'AUTHORITY')from dual;
---facebook.com
select parse_url('http://facebook.com/path/p1.php?query=1', 'USERINFO')from dual;
---空
2、字串連線函式(需要String型別): concat和concat_ws
用法:
concat(str1,SEP,str2,SEP,str3,……) 或者
concat_ws(SEP,str1,str2,str3, ……) (SEP為連線符)
舉例:
select concat('江蘇省','-','南京市','-','玄武區','-','徐莊軟體園');
---江蘇省-南京市-玄武區-徐莊軟體園
select concat_ws('-','江蘇省','南京市','玄武區','徐莊軟體園');
---江蘇省-南京市-玄武區-徐莊軟體園
3、當前的系統時間:unix_timestamp() from_unixtime
用法:
unix_timestamp() 或者
from_unixtime(unix_timestamp(),"patten")
舉例:
select unix_timestamp()
---1484532291
select from_unixtime(unix_timestamp(),'yyyy-MM-dd HH:mm:ss');
---2020-12-12 08:32:15
4、字串替換函式(將字串A 中的B 用 C 替換):regexp_replace
用法:
regexp_replace(string A, string B, string C)
舉例:
select regexp_replace('www.tuniu.com','tuniu','jd');
---www.jd.com
5、重複N次字串:repeat
用法:
repeat(string str, int n)
舉例:
select repeat('ab',3);
---ababab
6、補齊字串:lpad rpad
用法:
lpad(string str, int len, string pad)
或者
rpad(string str, int len, string pad)
舉例:
select lpad('ab',7,'k'); ---kkkkkab
select rpad('ab',7,'k'); ---abkkkkk
7、 刪除字串兩邊的空格(中間的會保留):trim
用法:
trim(string A), ltrim(string A) ,rtrim(string A)
舉例:
select trim(' kim bo ') ---kim bo
select ltrim(' kim bo ') ---kim bo
select rtrim(' kim bo ') --- kim bo