zoukankan      html  css  js  c++  java
  • Oracle字符串函数-Translate()总结

    Oracle的Translate(expr,from_string,to_string)是字符串操作函数,实现from_string,to_string字符的一 一替换

    1)典型示例:

    select translate('abcdef','abc','123') from dual;

    输出:

    TRANSLATE('ABCDEF','ABC','123'

    --------------------------------------------

    123def

    实现:将字符串‘abcdef’中的‘abc’替换为‘123’对应字符一 一替换(实现from_string与to_string以字符为单位,对应字符一 一替换),其它保持不变。

    2)一 一替换示例:from_string对应to_string位置没有对应字符

    select translate('abcdef','abc','12') from dual;

    输出:

    TRANSLATE('ABCDEF','ABC','12')

    -------------------------------------------

    12def

    3)一 一替换示例:from_string比to_string字符少

    select translate('abcdef','ab','123') from dual;

    输出:

    TRANSLATE('ABCDEF','AB','123')

    -------------------------------------------

    12cdef

    4)一 一替换示例:from_string比to_string字符少

    select translate('abcdef','#ab','123') from dual;

    输出:

    TRANSLATE('ABCDEF','#AB','123')

    -------------------------------------------

    23cdef

    5)一 一替换示例:to_string为''串

    select translate('abcdef','#ab','') from dual;

    输出:

    TRANSLATE('ABCDEF','#AB','')

    -------------------------------------------

    总之from_string,to_string对应字符替换,没有则不用替换,熟悉了上面的几个例子,就知道translate(expr,from_string,to_string)的正确用法了。

  • 相关阅读:
    tf.placeholder函数说明
    网易雷火 游戏研发一面 5.7
    【python3】with的用法
    一分钟理解softmax函数(超简单)
    网易雷火 笔试 4.25
    cun
    HDU-2045-RPG上色(递推)
    HDU-2050-折线分割平面 (递推)
    POJ-2389-Bull Math(高精度乘法)
    HDU-1002-A + B Problem II(高精度加法)
  • 原文地址:https://www.cnblogs.com/handhead/p/11580645.html
Copyright © 2011-2022 走看看