Home  >  Article  >  Database  >  oracle与sql 的区别(常用函数)(3)_MySQL

oracle与sql 的区别(常用函数)(3)_MySQL

WBOY
WBOYOriginal
2016-06-01 13:50:50980browse

ORACLE函数

bitsCN.com

    rn S:select patindex('%d%q%','sdsfasdqe') value O:oracle没发现,但是instr可以通过第四个参数控制出现次数select INSTR('sdsfasdqe','sd',1,2) value from dual 返回6

    24.求子串S:select substring('abcd',2,2) value O:select substr('abcd',2,2) value from dual

    25.子串代替 返回aijklmnef S:SELECT STUFF('abcdef', 2, 3, 'ijklmn') value O:SELECT Replace('abcdef', 'bcd', 'ijklmn') value from dual

    26.子串全部替换

    S:Replace

    O:select Translate('fasdbfasegas','fa','我' ) value from dual

    27.长度S:len,datalength

    O:length

    28.大小写转换 lower,upper
   29.单词首字母大写
    S:没发现

    O:select INITCAP('abcd dsaf df') value from dual

    30.左补空格(LPAD的第一个参数为空格则同space函数)

    S:select space(10)+'abcd' value

    O:select LPAD('abcd',14) value from dual

    31.右补空格(RPAD的第一个参数为空格则同space函数)

    S:select 'abcd'+space(10) value

    O:select RPAD('abcd',14) value from dual

    32.删除空格S:ltrim,rtrim O:ltrim,rtrim,trim

    33. 重复字符串S:select REPLICATE('abcd',2) value

    O:没发现

    34.发音相似性比较(这两个单词返回值一样,发音相同) S:SELECT SOUNDEX ('Smith'), SOUNDEX ('Smythe') O:SELECT SOUNDEX ('Smith'), SOUNDEX ('Smythe') from dual SQLServer中用SELECT DIFFERENCE('Smithers', 'Smythers') 比较soundex的差返回0-4,4为同音,1最高

  --------------日期函数

    35.系统时间

    S:select getdate() value

    O:select sysdate value from dual

    36.前后几日

    直接与整数相加减

    37.求日期S:select convert(char(10),getdate(),20) value

    O:select trunc(sysdate) value from dual

    select to_char(sysdate,'yyyy-mm-dd') value from dual

    38.求时间S:select convert(char(8),getdate(),108) value O:select to_char(sysdate,'hh24:mm:ss') value from dual

    39.取日期时间的其他部分

    S:DATEPART和DATENAME函数(第一个参数决定)

    O:to_char函数第二个参数决定

    参数---------------------------------下表需要补充

    year yy, yyyy quarter qq, q (季度) month mm, m (m O无效) dayofyear dy, y (O表星期) day dd, d (d O无效) week wk, ww (wk O无效)

    weekday dw (O不清楚)

    Hour hh,hh12,hh24 (hh12,hh24 S无效) minute mi, n (n O无效) second ss, s (s O无效)

    millisecond ms (O无效)

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

    40.当月最后一天

    S:不知道

    O:select LAST_DAY(sysdate) value from d

 

bitsCN.com
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn