在Oracle的SQL中,其實有很多好用的function,今天用到的是Trim,雖然不是今天遇到的問題,但可以將用法紀錄一下:
Ttim主要是可以將string的開頭或結尾的某些特殊字元刪除掉,如空格等等的,非常好用。
語法:trim( [ leading | trailing | both [ 特殊字元 ] ] 字串 )
1. leading :將字串前端含有[特殊字元]的字元刪除
2. trailing :將字串後端含有[特殊字元]的字元刪除
3. both :將字串前端與後端含有[特殊字元]的字元刪除
4. 如果以上三個都不選的話,預設是使用both的方式將含有[特殊字元]的字元刪除
5. 如果沒有設定要刪除之[特殊字元],預設會刪除空白字元(space)
範例:
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'
參考:http://www.techonthenet.com/oracle/functions/trim.php
沒有留言:
張貼留言