집 >데이터 베이스 >MySQL 튜토리얼 >sql 字符串处理函数(1/5)
下面列出了大家常用的sql 字符串处理函数,好了开始看
绝对值
sql:select abs(-1) value
o:select abs(-1) value from dual
2.取整(大)
s:select ceiling(-1.001) value
o:select ceil(-1.001) value from dual
3.取整(小)
s:select floor(-1.001) value
o:select floor(-1.001) value from dual
4.取整(截取)
s:select cast(-1.002 as int) value
o:select trunc(-1.002) value from dual
5.四舍五入
s:select round(1.23456,4) value 1.23460
o:select round(1.23456,4) value from dual 1.2346
6.e为底的幂
s:select exp(1) value 2.7182818284590451
o:select exp(1) value from dual 2.71828182
7.取e为底的对数
s:select log(2.7182818284590451) value 1
o:select ln(2.7182818284590451) value 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
----------数学函数