资源描述:
《sqlserver和oracle内置函数比较》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、数学函数1.绝对值SQL:selectabs(-1)valueO:selectabs(-1)valuefromdual2.取整(大)S:selectceiling(-1.001)valueO:selectceil(-1.001)valuefromdual3.取整(小)S:selectfloor(-1.001)valueO:selectfloor(-1.001)valuefromdual4.取整(截取)S:selectcast(-1.002asint)valueO:selecttrunc(-1.002)valuefromdual5.
2、四舍五入S:selectround(1.23456,4)value1.23460O:selectround(1.23456,4)valuefromdual1.23466.e为底的幂S:selectExp(1)value2.7182818284590451O:selectExp(1)valuefromdual2.718281827.取e为底的对数S:selectlog(2.7182818284590451)value1O:selectln(2.7182818284590451)valuefromdual;18.取10为底对数S:se
3、lectlog10(10)value1O:selectlog(10,10)valuefromdual;19.取平方S:selectSQUARE(4)value16O:selectpower(4,2)valuefromdual1610.取平方根S:selectSQRT(4)value2O:selectSQRT(4)valuefromdual211.求任意数为底的幂S:selectpower(3,4)value81O:selectpower(3,4)valuefromdual8112.取随机数S:selectrand()valueO:
4、selectsys.dbms_random.value(0,1)valuefromdual;13.取符号S:selectsign(-8)value-1O:selectsign(-8)valuefromdual-1----------数学函数14.圆周率S:SELECTPI()value3.1415926535897931O:不知道15.sin,cos,tan参数都以弧度为单位例如:selectsin(PI()/2)value得到1(SQLServer)16.Asin,Acos,Atan,Atan2返回弧度17.弧度角度互换(SQL
5、Server,Oracle不知道)DEGREES:弧度-〉角度RADIANS:角度-〉弧度---------数值间比较18.求集合最大值S:selectmax(value)valuefrom(select1valueunionselect-2valueunionselect4valueunionselect3value)aO:selectgreatest(1,-2,4,3)valuefromdual19.求集合最小值S:selectmin(value)valuefrom(select1valueunionselect-2value
6、unionselect4valueunionselect3value)aO:selectleast(1,-2,4,3)valuefromdual20.如何处理null值(F2中的null以10代替)S:selectF1,IsNull(F2,10)valuefromTblO:selectF1,nvl(F2,10)valuefromTbl数值间比较21.求字符序号S:selectascii('a')valueO:selectascii('a')valuefromdual22.从序号求字符S:selectchar(97)valueO:s
7、electchr(97)valuefromdual23.连接S:select'11'+'22'+'33'valueO:selectCONCAT('11','22')
8、
9、33valuefromdual23.子串位置--返回3S:selectCHARINDEX('s','sdsq',2)valueO:selectINSTR('sdsq','s',2)valuefromdual23.模糊子串的位置--返回2,参数去掉中间%则返回7S:selectpatindex('%d%q%','sdsfasdqe')valueO:oracle没发现,
10、但是instr可以通过第四霾问刂瞥鱿执问?BR>selectINSTR('sdsfasdqe','sd',1,2)valuefromdual返回624.求子串S:selectsubstring('abcd',2,2)valueO:selectsub