집 >데이터 베이스 >MySQL 튜토리얼 >oracle与sql 的区别(常用函数)(2)_MySQL
ORACLE函数
bitsCN.comvalue from dual; 1
8.取10为底对数
S:select log10(10) value 1
O:select log(10,10) value from dual; 1
9.取平方
S:select SQUARE(4) value 16
O:select power(4,2) value from dual 16
10.取平方根
S:select SQRT(4) value 2
O:select SQRT(4) value from dual 2
11.求任意数为底的幂S:select power(3,4) value 81 O:select power(3,4) value from dual 81
12.取随机数
S:select rand() value
O:select sys.dbms_random.value(0,1) value from dual;
13.取符号
S:select sign(-8) value -1
O:select sign(-8) value from dual -1
----------三角函数相关
14.圆周率S:SELECT PI() value 3.1415926535897931
O:不知道
15.sin,cos,tan 参数都以弧度为单位
例如:select sin(PI()/2) value得到1(SQLServer)
16.Asin,Acos,Atan,Atan2 返回弧度
17.弧度角度互换(SQLServer,Oracle不知道)
DEGREES:弧度-〉角度
RADIANS:角度-〉弧度
---------数值间比较
18. 求集合最大值
S:select max(value) value from
(select 1 value
union
select -2 value
union
select 4 value
union
select 3 value)a
O:select greatest(1,-2,4,3) value from dual
19. 求集合最小值
S:select min(value) value from
(select 1 value
union
select -2 value
union
select 4 value
union
select 3 value)a
O:select least(1,-2,4,3) value from dual
20.如何处理null值(F2中的null以10代替) S:select F1,IsNull(F2,10) value from Tbl O:select F1,nvl(F2,10) value from Tbl
--------字符串函数
21.求字符序号
S:select ascii('a') value
O:select ascii('a') value from dual
22.从序号求字符
S:select char(97) value
O:select chr(97) value from dual
23.连接
S:select '11'+'22'+'33' value
O:select CONCAT('11','22')||33 value from dual
23.子串位置 --返回3 S:select CHARINDEX('s','sdsq',2) value O:select INSTR('sdsq','s',2) value from dual
23.模糊子串的位置 --返回2,参数去掉中间%则返回7 //
bitsCN.com